returning query result to a list c#
I am working on a project where I am phasing out Entity framework from an
existing system.
I got
public List<GSP> GetOwnAirline()
{
var res = from own in entity.GSP where own.Description == "Own
Airline" select own;
return res.ToList();
}
To bypass this i did
public List<GSP> GetOwnAirline()
{
string get_ = "SELECT * FROM " + Adm.schema_ + "Adm.GSP WHERE
Description = 'Own Airline'";
ccs = new SqlConnection(Adm.COnnectionString);
//convey transaction to db
cmd = ccs.CreateCommand();
ccs.Open();
cmd.CommandText = get_;
var res =cmd.ExecuteScalar();
ccs.Close();
return res.ToList();
}
But the.ToList seems not to be recognised in this situation. Where did i
go wrong guys ?
No comments:
Post a Comment