C#Linq To Entity Frame工作无法绑定 [英] C# Linq To Entity Frame work failing to bind
本文介绍了C#Linq To Entity Frame工作无法绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的会员,
在这方面有谁可以帮助我。我试图在我的C#窗体表单项目中使用Linq To Entity框架工作执行ras SQL查询。代码如下。
Dear Members,
Can anybody help me in this regard. I am trying to execute a ras SQL Query using Linq To Entity frame work in my C# windows forms project. Code is as follows.
string Query = "SELECT" +
"dbo.DataAccount.PatientAccountNumber, " +
"dbo.DataAccount.PatientName, " +
"dbo.DataAccount.BARStatus_ORPH," +
"dbo.DataAccount.AdmitDate," +
"dbo.DataAccount.ServiceDate," +
"dbo.DataCodes.CPT1," +
"dbo.DataCodes.CPT2," +
"dbo.DataCodes.CPT4," +
"dbo.DataCodes.CPT6," +
"dbo.Diagnosis.DX1," +
"dbo.Diagnosis.DX1DESC" +
"FROM " +
"(dbo.DataCodes INNER JOIN " +
"(dbo.DataAccount INNER JOIN dbo.Diagnosis " +
"ON dbo.DataAccount.RowID = dbo.Diagnosis.DXRowID) " +
"ON dbo.DataAccount.RowID = dbo.DataCodes.RowID)";
EntityConnection eConn = new EntityConnection(security.GetConnectionStringForPIAPratice(Server, DataBaseName, password));
eConn.Open();
using (Etities entity = new Entities(eConn))
{
var queryres = entity.ExecuteStoreQuery<dynamic>(Query , null);
DGVQueryResults.DataSource = queryres.ToList();
}
但是在绑定到Datagrdi视图后它什么也没显示。但我观察到var变量结果查询是持有对象。
谢谢&问候。
But after binding to Datagrdi view it is showing nothing. But i observed that var variable result queryres is holding objects.
Thanks & Regards.
推荐答案
为什么你会这样做?为什么使用EF基本上作为老式的SQL服务器连接?
也许如果你创建了强类型的类,你的数据网格能够找出如何处理它们?如果那里有数据,问题在于datagrid处理它。当您在最后一刻调用ToList时,我假设您在调试器中看到DataSource中的数据,因此请尝试创建一个真正的类,看看是否有帮助。
Why on earth would you do this ? Why use EF basically as an old fashioned SQL server connection ?
Perhaps if you created strongly typed classes, your datagrid would be able to work out how to deal with them ? If there's data there, the issue is with the datagrid dealing with it. As you call ToList at the last minute, I assume you're seeing data in the DataSource in the debugger, so try creating a real class and see if that helps.
这篇关于C#Linq To Entity Frame工作无法绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文