开发者

Entity binding to select table columns

I am just learning to use the Entity framework and I wondered how I can bind to a select few columns with my WPF Toolkit datagrid?

Can someone give me an example?

I've tried to set the DataContext to the Person Entity for example and then set the Itemsource binding path to a single column of开发者_如何学编程 the table, but it does not work.


You would do something more along the lines of a LINQ statement for the column you want, then binding to that variable. For example, if ctx is your data context:

var data = from p in ctx.Person
           select new { Name = p.Name };

That would give you an IQueryable list containing 1 variable with a Name field for each person. You would then bind to that list.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜