I would like to store and query a calculated field. For instance, the fallowing table:
public class ModelTest
{
[Key]
public int Id { get; set; }
public int A { get; set; }
public int B { get { return CSharpFunction(A) ; } }
}
I want be able to query the values from the table like this.
results = db.ModelTests.Where(m => m.B = 10);
However i got the fallowing error:
The specified type member 'B' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
The only way is to query ALL entries from the db db.ModelTests.ToList()
and then selects based on the Where statent later.
Is possible to store the B
value into the db and optimize this kind of query ?
(other solutions are welcome too).
thanks