Search for existing suggestions

Persist/Query Calculated Properties (read-only)

This is a very useful feature that is supported in NHibernate. Given this property in the Order Entity:

public decimal OrderTotal
{
get { return Items.Sum(o => o.Total); }
}

EF should persist this "read-only" property which can also be used in LINQ queries.

var results = from order in DbSet<Order>
where order.OrderTotal > 100
select order;

I believe a current work around is to include an empty protected setter but that has code smell all over it.

2 votes
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

Mike Rowley shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Ricardo Peres commented  ·   ·  Flag as inappropriate

    Allow having properties that contain the result of formulas. The formula should be specified in a new attribute or fluently.

Feedback and Knowledge Base