I have no difficulty adding records to my database using the class I created
public class KElement
{
public string Key { get; set; } //created with a custom method using timestamp and internal company codes
public string Type { get; set; } //currently hard-coded as equipment
public string BarCode { get; set; } //code 39
public string ItemName { get; set; }
public string Manufacturer { get; set; }
}
According the the documentation it appears I should be able to use a QueryAsync method to return the data, then add an await foreach to add it to my class. Based on the documentation I wrote:
private async void BtnGetRecords_Click(object sender, EventArgs e)
{
KElement Element = new KElement();
var cluster = await Cluster.ConnectAsync("http://xxx.xx.x.xxx", "userName", "userPassword");
var query = @"SELECT * FROM `warehouse` WHERE manufacturer = $1";
var queryResult = await cluster.QueryAsync<dynamic>(query, options => options.Parameter("Monoprice")
); //if I put at break point here and hover over queryResult, it shows the correct data was returned and three records are present.
await foreach ( var record in queryResult) //taken from the documentation
{
Element.Type = record.type; //returns null so nothing is added to my KElement class.
Element.BarCode = record.barCode; //returns null so nothing is added to my KElement class.
Element.Manufacturer = record.manufacturer; //returns null so nothing is added to my KElement class.
Element.ItemName = record.itemName; //returns null so nothing is added to my KElement class.
RecordHandler(); //method to put display data on user screen
}
await cluster.DisposeAsync();
}
Can anyone tell me where Iām going wrong?