vb.net - Entity Framework 6 Linq results for master-detail -


i'm trying create master-detail model using following tables:

orders ordid   date            custid ======================================== 1       01.01.2014      1 2       02.02.2014      2 3       03.03.2014      2 4       01.01.2014      4  orderdetails id      ordid   prodid  quantity ======================================== 1       1       1       2 2       1       2       1 3       2       3       3 4       2       4       5 

now want have orders datagridview , orderdetails datagridview.
orders dgv should this:

orders ordid   date            customer    status ============================================ 1       01.01.2014      custone     100% 2       02.02.2014      custtwo     62.5% 

and details dgv (filtered on selected order):

orderdetails id      prod        quantity    status ====================================== 1       prodone     2       100% 2       prodtwo     1       100% 3       prodthree   3       0% 4       prodfour    5       100% 

lets status field in orderdetail calculated based on data other 3-4 tables. these tables shown on form, , contain product/order related details (production status, suppliers, etc.).
did using dataset , datatables getting tables database dataset, making calculations using linq results populating other tables had necessary relations between them, bind them datagridviews using bindingsources master-detail.
i'm trying achive using ef. goal minimize data fetched database, , perform calculations in memory, rather in database.
there way create model in ef, contain filed need, , data coming context, not database.(i'm pulling products table, clients table, orderstable, orderdetails table, etc. database context. tha table behind orders datagridview created using joins these tables. dont want data in table database using storedprocedures, want using linq tables in context).

the questions are:
have entity:

order properties: ordid, date, custid     , navigation properties: customer, orders. 

and entity:

orderdetail properties: id, ordid, prodid, quantity     , navigation properties: order, product. 

how add property entity, , property calculated, kind of expression in datatable. how display orders collection on datagridview, showing customer info on every row.

whilst there long way of answering question, believe there alternative trying achieve.

for calculated property, need create partial class calculated property, need ensure navigation property populated first:

'pre populate data , include additional navigated items

dim query = datacontext.orders.include("orderdetails").where(function(t) t.orderid = x) 

'create new partial class on orderdetails entity create property calculate status:

public partial class orderdetails     public readonly property status string         return = (100 / me.quantity) & "%"     end property end class 

ideally should create view model each datagrid, populate can create functional / calculational properties specific datagrid there, creating partial classes on model can re-use in application.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -