I am making a run time sql query and getting data from database using LINQ SqlQuery<>
SchoolSoulLibrary.SchoolSoulDataEntities ss = new SchoolSoulLibrary.SchoolSoulDataEntities();
string query1;
var li = ss.Database.SqlQuery<MasterBank>(query1).ToList();
where MasterBank class is
public Partial class MasterBank
{
public MasterBank()
{
}
public decimal BankId { get; set; }
public string BankName { get; set; }
public Nullable<decimal> UserId { get; set; }
public Nullable<decimal> SchoolId { get; set; }
}
if i am executing this query
query1 = "Select * from MasterBank"; or
query1 = "Select BankId,BankName,UserId ,SchoolId from MasterBank";
Its not giving any error and returning all data
but if i am executing this query
query1 = "Select BankName,SchoolId from MasterBank";
error occured
i understand the reason of this error that it return a result of the type of class MasterBank but what can i do now because query1 is generating runtime with random no of properties of class MasterBank.
is there any other alternative of doing it rather than SqlQuery<>
kindly suggest
decimaland not anInt32orInt64(or even aGuid).