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__7a1[<>f__anonymoustype03[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

Popular posts from this blog

python - Alternative to referencing variable before assignment -

vb.net - How to ignore if a cell is empty nothing -

Sort a complex associative array in PHP -