asp.net mvc - Retrieving associated elements based on ID in entity query -
i have entity query groups number of property reviews property. im having trouble query pull rest of data on property based on propertyid. thanks!
example results:
|propertyid | numofreviews | streetaddress | city | 1 14 1600 speaker st. miami
query:
var query1 = r in db.reviews group r r.propertyid g select new { propertyid = g.key, numofreviews = g.count() //get rest of data };
property model:
public partial class property { public int propertyid { get; set; } public string streetaddress { get; set; } public string city { get; set; } public string zip { get; set; } public string state { get; set; } public string country { get; set; } public string route { get; set; } public virtual icollection<review> reviews { get; set; } }
review model:
public partial class review { public int reviewid { get; set; } public int propertyid { get; set; } public int rating { get; set; } public string review { get; set; } public virtual property property { get; set; } }
can come @ opposite direction?
var query = p in db.properties select new { propertyid = p.propertyid, numofreviews = p.reviews.count() //grab remaining properties off of p variable need };
Comments
Post a Comment