c# - LINQ conversion to List object -
i using following code return ilist:
filename = path.getfilename(files[i]); ilist<datax> querylistfromftp = datax.getlistfromftp(filename); querylistfromftp = (ilist<datax>)querylistfromftp .select(x => new { x.user_id, x.date, x.application_id }) .tolist() .distinct();
however keep getting error:
unable cast object of type 'd__7a
1[<>f__anonymoustype0
3[system.string,system.string,system.string]]' type 'system.collections.generic.ilist`1[dataxlibrary.datax]'.
what doing wrong?
if want list < datax > need is:
ilist<datax> querylistfromftp = datax.getlistfromftp(filename).distinct().tolist(); // use querylistfromftp here.
if want list of different type of object result of .select, need store result in list of object of type i.e. anonymous if that's want.
Comments
Post a Comment