by passing single column name binding records but i want to get records by passing multiple column names dynamically using entity framework.
please provide soultion regarding this
I have tried like this...
public List GetRecords(List Columns,string tablename)
{
using (var Context = new MCPEntities())
{
string columnnames = string.Join(",", Columns);
string Query = "SELECT " + columnnames + " FROM " + tablename + " ";
var Records = Context.Database.SqlQuery(Query).ToList();
return Records.ToList();
}
}
{
using (var Context = new MCPEntities())
{
string columnnames = string.Join(",", Columns);
string Query = "SELECT " + columnnames + " FROM " + tablename + " ";
var Records = Context.Database.SqlQuery
return Records.ToList();
}
}

Rajkiran SwainPosted Jun 19, 2017, 3:02 AM
Seshu BPosted Jun 19, 2017, 2:36 AM
The result type 'System.Collections.Generic.IEnumerable`1[System.String]' may not be abstract and must include a default constructor
Irshad JmPosted Jun 19, 2017, 2:25 AM
Seshu BPosted Jun 19, 2017, 2:23 AM
"The data reader has more than one field. Multiple fields are not valid for EDM primitive or enumeration types."
Sakthivel GanesanPosted Jun 19, 2017, 2:19 AM