display list with complex value
-
Monday, April 02, 2012 1:56 PM
(I use entity / MVVM)
My list need display (with datapager)
- Product name
- Complex calculation to determine the product price (stored procedure)I dont see how to link data directly from entity without losing typing of list
I try to use an sql view and do a relationship with entity but it's not possible to run a stored procedure in a sql view
If I make a converter to display the price I need to run my stored procedure on each element (this is not that great) but in addition I have a problem to manage an asynchronous call in a converter!
I dont see what the right solution and to apply
All Replies
-
Tuesday, April 03, 2012 2:00 AM
Hi,
I suppose you work with RIA services? You can try the following:
You can add a property server side to your entity.
Entities generated from entity framework are always partial:
You add a class (namespace must be the same of the generated entity):
public partial class MyEntity
{public int MyCalculatedValue{get; set;}
}
In the (custom) query method you can do the following:
public IQueryable<MyEntity> GetMyEntitiesCustom()
{//your qry
var tempLst = this.ObjectContext.MyEntities.ToList();foreach(var item in tempLst)
{//before you can call you SP on your objectcontext, you should import your SP as function in your entity model
item.MyCalculatedValue = this.ObjectContext.MyStoredProdecure();
}
return tempLst.AsQueryable<MyEntity>();}
Regards,
-
Tuesday, April 03, 2012 8:40 AM
This is the answer I was looking
For complete I need do :
public partial class MyEntity
{[DataMember()]
public int MyCalculatedValue{get; set;}
}
else the property is not available in my viewmodel
Thx

