Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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();               
            }

But after binding to Datagrdi view it is showing nothing. But i observed that var variable result queryres is holding objects.

Thanks & Regards.
Posted
Updated 23-Sep-13 17:37pm
v2

1 solution

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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900