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
Post a Comment