ef4 map model defined function to property
I've seen model defined functions used in in-code queries (queries written by the developer using Linq etc) and I'm wondering if there's any way to map a model-defined function to an entity property so that EF4 will automatically query the database using it.
For example:
Suppose I have a Product
class and an Order
class and that Product
has a TotalSold
property. Ideally I would like to create a model defined function like:
select sum(o.quantity) from order, product where o.productid = product.productid
and bind that to the TotalSold
property of Product
so that every query for a given Product
would auto generate an inner select that would populate the TotalSold
property.
Does this make sense? Is it possible?
我找到了一个足够好的解决方案,并在http://statichippo.com/archive/2011/01/26/Mapping-a-computed-property-in-EF4.aspx上发表了博文
链接地址: http://www.djcxy.com/p/90198.html上一篇: 第一:TPH方法?
下一篇: ef4地图模型定义的函数属性