c# - Get object in LINQ expression -


there want file's name in linq expression (i'm not sure if ok ask this)

please @ code, find "here how file's name in db???"

public static ienumerable<string> getfiles(list<string> srcfiles) {     var filepaths = new list<string>();     using (var db = new contentmgmtcontext())     {         foreach (var fileinfo in srcfiles.select(file => new fileinfo(file)))         {             if (db.files.any(o => o.filename.tolower() == fileinfo.name.tolower() || o.filesize == fileinfo.length.tostring()))              {                 console.writeline("{0} exist in db", fileinfo.name);                 console.writeline("conflict file in db is: {0}",here how file's name in db???);             }             else             {                 filepaths.add(fileinfo.fullname);             }         }     }     return filepaths; } 

you try collecting every db entry matches criteria first

public static ienumerable<string> getfiles(list<string> srcfiles) {     var filepaths = new list<string>();     using (var db = new contentmgmtcontext())     {         foreach (var fileinfo in srcfiles.select(file => new fileinfo(file)))         {             var matches = db.files.where(o => o.filename.tolower() == fileinfo.name.tolower() ||                 o.filesize == fileinfo.length.tostring())              if (matches.count() > 0)             {                 foreach (var match in matches)                 {                     console.writeline("{0} exist in db", fileinfo.name);                     console.writeline("conflict file in db is: {0}",match.filename);                 }             }             else             {                 filepaths.add(fileinfo.fullname);             }         }     }     return filepaths; } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -