Creating a Linq statement to create objects -
if created linq statement shown below, works fine.
var jobs = in ctx.myexport select new { filename = a.filepath, jobid = a.id, };
if want use class rather anonymous type following error "cannot convert lambda expression type 'string' because not delegate type".
here code want work:
var jobs = in ctx.myexport select new myclass { filename = a.filepath, jobid = a.id, };
and here class:
public class myclass { public string filename { get; set; } public guid jobid { get; set; } }
can tell me doing wrong , how fix it?
the above code correct , getting error message because of code didn't showed us.
you trying assign unmaterialized query string variable result in error. changing type ienumerable materialize query whether use or not taken out data base.so solution not recomended.
the answer materialize query before usage , assume doing foreach on collection ,so jobs.asenumerable() or jobs.tolist() (depending on want it) should doing.
Comments
Post a Comment