实体框架
我使用以下代码。但是,我尝试使用表名称来检索数据和实体。
SalesInvoiceList = (from p in entities.SalesCards
select new SalesInvoice
{
ID = p.ID,
InvoiceNo = p.InvoiceNo,
DateTime = p.DateTime,
ContactName = p.CustomerCard.ContactName,
CompanyName = p.CustomerCard.CompanyName
}).ToList();
我希望能够执行以下操作或类似的操作,
SalesInvoiceList = (from p in "DBO.SALESCARD"
select new SalesInvoice
{
ID = p.ID,
InvoiceNo = p.InvoiceNo,
DateTime = p.DateTime,
ContactName = p.CustomerCard.ContactName,
CompanyName = p.CustomerCard.CompanyName
}).ToList();
最好的方法是什么?
谢谢
I Have the following code that I use. However, I'm trying to use the Table Name to retrieve the data and the entities.
SalesInvoiceList = (from p in entities.SalesCards
select new SalesInvoice
{
ID = p.ID,
InvoiceNo = p.InvoiceNo,
DateTime = p.DateTime,
ContactName = p.CustomerCard.ContactName,
CompanyName = p.CustomerCard.CompanyName
}).ToList();
I want to be able to do the following or something similar
SalesInvoiceList = (from p in "DBO.SALESCARD"
select new SalesInvoice
{
ID = p.ID,
InvoiceNo = p.InvoiceNo,
DateTime = p.DateTime,
ContactName = p.CustomerCard.ContactName,
CompanyName = p.CustomerCard.CompanyName
}).ToList();
What is the best way to do that?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您始终可以使用 EF 将某些查询映射到您的对象
You can always use EF just to map some query to your object
不确定我是否理解您想要正确执行的操作,但如果我理解的话,这应该是您尝试执行的操作的一个简单解决方案。
Not sure if i am understanding what you want to do correctly but if i am this should be a easy solution to what you are trying to do.