I am currently building a cross-platform mobile app using XamarinForms and an Azure Mobile app on the backend and I'm running into an issue with the InsertAsync function. Whenever I call it, it successfully inserts the data into my table but immediately throws an InvalidOperation exception with the message " Error converting data type nvarchar to numeric". Any idea why its throwing this exception/any possible fixes?
My client side model(matches the server side table):
public class Bet
{
[PrimaryKey]
[JsonProperty(PropertyName = "Id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "Name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "endDate")]
public int endDate { get; set; }
[JsonProperty(PropertyName = "Description")]
public string Description { get; set; }
[JsonProperty(PropertyName = "Payout1")]
public string Payout1 { get; set; }
[Version]
[JsonProperty(PropertyName ="version")]
public byte[] version { get; set; }
[JsonProperty(PropertyName = "createdAt")]
public DateTime? createdAt { get; set; }
[JsonProperty(PropertyName = "updatedAt")]
public DateTime? updatedAt { get; set; }
the offending code:
public async void addBet(Bet myBet, List<UserBet> myUserBets)
{
IMobileServiceTable<Bet> betTable = client.GetTable<Bet>();
myBet.ID = null;
await betTable.InsertAsync(myBet);
}
My table:
Name Type IS Index
id String true
Name String false
endDate Number false
Description String false
Payout1 String false
version Version false
createdAt Date false
updatedAt Date false
deleted Boolean false