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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -