如何在LINQ中的Datatable中填充整个表 [英] how to fill entire table in Datatable usin LINQ in

查看:101
本文介绍了如何在LINQ中的Datatable中填充整个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var data = from sel in db.CustomerTBLs select sel;


我为datatable中的存储表做什么.


what i do for store table in datatable.

推荐答案

您可以使用CopyToDataTable方法,但是您只需要选择所需的字段即可.如果您具有CustomerTBLs的子实体,它将不起作用.
示例代码:
You can use CopyToDataTable method, but you need to select only the field you want. if you have sub entities of CustomerTBLs it will not work.
Sample code:
var datatable = db.CustomerTBLs.Select(c=> new { x.Id,
                                       Contact = x.Contact.Name,
                                       Address = x.Address.Address
                                      }).CopyToDataTable();


这篇关于如何在LINQ中的Datatable中填充整个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆