c# - Select two columns from the table via linq -
i utilize query below columns(20 more) in entity framework linq. because of out of memory exception, want 2 of them. 1 "filename", other 1 "filepath". how modify code?
var query = dbcontext.table1 .where(c => c.facilityid == facilityid && c.filepath != null && c.timestationoffhook < olddate) .orderby(c => c.filepath) .skip(1000) .take(1000) .tolist(); foreach(var t in query) { console.writeline(t.filepath +"\\"+t.filename); }
var query = dbcontext.table1.where(c => c.facilityid == facilityid && c.filepath != null && c.timestationoffhook < olddate) .orderby(c => c.filepath) .skip(1000) .take(1000) .select(c => new { c.filepath, c.filename }) .tolist(); foreach(var t in query) { console.writeline(t.filepath +"\\"+t.filename); }
you need utilize select
.
c# linq
No comments:
Post a Comment