5
Answers

How to get records by passing multiple column names in MVC5

Seshu B

Seshu B

7y
460
1
Hi all..
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<string> GetRecords(List<string> Columns,string tablename)
{
using (var Context = new MCPEntities())
{
string columnnames = string.Join(",", Columns);
string Query = "SELECT " + columnnames + " FROM " + tablename + " ";
var Records = Context.Database.SqlQuery<string>(Query).ToList();
return Records.ToList();
}
Answers (5)