Seshu B

Seshu B

  • NA
  • 442
  • 146.3k

How to get records by passing multiple column names in MVC5

Jun 19 2017 1:51 AM
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)