I have a table with the following fields:
dbo.AccountProbability
StageKey (binary(16), not null)
AccountId (int, not null)
Probability (real, null)
IsCurrent (bit, not null)
It is mapped in Entity Framework like so:
[Table("dbo.AccountProbability")]
public partial class AccountProbability
{
[Required]
[MaxLength(16)]
public byte[] StageKey { get; set; }
public int AccountId { get; set; }
public double? Probability { get; set; }
public bool IsCurrent { get; set; }
}
When I try to map it to an object, in the below method, I get an error:
public async Task GetAccountProbabilities()
{
var repo = GetDatabaseRepo();
var validAcctProbs = repo.Where<AccountProbability>(
m => m.IsCurrent).ToList();
}
private static IDatabaseRepository GetDatabaseRepo()
{
var context =
new DbContext(ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString);
return new DatabaseRepository(context);
}
It fails on validAcctProbs
when it's putting it to list, with the error: The 'Probability' property on 'AccountProbability' could not be set to a 'System.Single' value. You must set this property to a non-null value of type 'System.Double'.
I believe that reals in TSQL are doubles in EF.
EDIT: I do not believe this is a dupe because the previous question was specifically about SQLite and faulty mappings in that driver. This is for Microsoft TSQL.
float
). but it is correct that tsqlreal
maps to .NETdouble
: mappings – Cee McSharpface May 24 '17 at 19:42