linq - Cast the type 'System.Int64' to type 'System.Object' -


i'm trying export sql query result csv file, i'm having issues cast.

here's code :

var query = string.concat((from t in db.employees select t.id + "," + t.lastname+"\n" ).take(2000));  return file(new system.text.utf8encoding().getbytes(query), "text/csv", "report.csv"); 

but have following error : additional information: unable cast type 'system.int64' type 'system.object'. linq entities supports casting edm primitive or enumeration types.

can me on ? thanks

it looks ef unable translate string concatenation call sql. should able work around issue concatenating in memory:

var query = string.concat(     db.employees         .select(e => new {id, lastname})         .take(2000)         .asenumerable() // rest of query happens in memory         .select(p => p.id + "," + p.lastname) ); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -