c# - Entity Framework 6 Can't find error column -
i using mvc entity framework , gets following error.
the specified cast materialized 'system.int64' type 'system.string' type not valid.
error quite understandable , easy resolve , issue facing in sql query have plenty of columns, error details can't see column having specific issue , have go through columns 1 one.
string query= "select id,claim_no,emp_id,dept_id,location_id staff"; var ctx = new tiaentities() ctx.database.sqlquery<orm>(query).tolist()
i have viewed details in watch also, can't find column name.
model:-
public class orm { public int64 id { get; set; } public string claim_no { get; set; } public int64 emp_id { get; set; } public int64 dept_id { get; set; } public int64 location_id { get; set; } }
you can use these solutions:
var query = o in ctx.orm select new { id = o.id, claim_no = o.claim_no, emp_id = o.emp_id, dept_id = o.dept_id, location_id = o.location_id };
or
var query = ctx.orm.select(o => new orm { id = o.id, claim_no = o.claim_no, emp_id = o.emp_id, dept_id = o.dept_id, location_id = o.location_id });
the query's type is:
iqueryable<'a> query
Comments
Post a Comment