协会和约束! [英] Association and Bindings!
问题描述
我创建了一个有5个表的实体模型。我有一个自定义的formview(ASP.NET),它与Eval绑定。
如何在我的上下文中访问不同表中的列?
Eval("Customer")来自CustomerTable
Eval("PersonName")来自PersonTable
Eval(" OrderID")来自OrderTable
CustomEntity context = new CustomEntity();
$
var query = from context inOcon.Order.Include( "人")//希望包含所有5个表格....理想情况为:
   选择d;
$
frmView.DataSource = query.ToList(); frmView.DataBind();
I have created an Entity Model which has 5 tables. I have a custom formview (ASP.NET) which I bind with Eval.
How can I access columns from different tables in my context?
Eval("Customer") is from CustomerTable
Eval("PersonName") is from PersonTable
Eval("OrderID") is from OrderTable
CustomEntity context=new CustomEntity();
var query=from d in context.Order.Include("Person") // would like to include all the 5 tables....ideally
select d;
frmView.DataSource=query.ToList();frmView.DataBind();
此外,更新将如何运作?更新
Also how will the update work? Will the update
推荐答案
您可以在查询中继续包含Include语句。例如:
You can keep chaining Include statements on your query. For example:
context.Order.Include(" Person.Addresses")//包括订单的人和该人的地址
; .Include(" OrderDetails")//包含订单的订单详细信息
...
context.Order.Include("Person.Addresses") // Includes the Order's Person and that Person's Addresses
.Include("OrderDetails") // Includes the Order's OrderDetails
...
我有点困惑,因为FormView只显示一条记录,所以我不确定如何更新将与多个实体合作。否则,由于您没有使用DataSource,您可以在FormView上订阅ItemUpdating事件并从那里进行
更新。
I am a little confused though because a FormView will only show one record, so I'm not sure how Update will work with multiple entities. Otherwise, since you're not using a DataSource you can subscribe to the ItemUpdating event on the FormView and do the update from there.
如果要调用自定义更新在另一个类的例程中,您可能需要查看ObjectDataSource。如果您搜索"ObjectDataSource update",那么你应该找到很多结果。
If you want to call a custom update routine in another class, it may behoove you to look at the ObjectDataSource. If you search for "ObjectDataSource update" then you should find a lot of results.
这篇关于协会和约束!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!