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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -