Entity Framework: check if object exists and check if it has an associated object -


in many-to-many relationship between file , category want check if file exists , if so, if has categories (because there's chance may not have any) :

        public bool existsindbandhascategories(string path)     {         using (winfilecontextcontainer c = new winfilecontextcontainer())         {             return c.file.any((o => o.path == path));         }     }     

this checks if file path has record in database. got thread on site. truth told still not linq , lambdas, don't know how extend give me boolean categories well. in advance time.

you have add condition method (assuming have defined categories list of category in file class) :

return c.file.any((o => o.path == path && o.categories.any())); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -