I'm using RIA services SP2 and Entity Framework 5 (Generated from existing DB), however when I pass an entity object with a reference to another entity object, I do not get the referenced object. I am doing the .Include on the entity framework side, and also putting the "Include" attribute over the referenced entity. My classes look similar to this:
[MetadataTypeAttribute(typeof(ProfileValue.ProfileValueMetadata))]
public partial class ProfileValue
{
internal class ProfileValueMetadata
{
private ProfileValueMetadata()
{
}
[Key]
public int ValueID { get; set; }
public int ItemID { get; set; }
[Include]
[Composition]
[Association("ProfileValue_ProfileItem", "ItemID", "ItemID")]
public virtual ProfileItem ProfileItem { get; set; }
public string Value { get; set; }
}
}
and:
[MetadataTypeAttribute(typeof(ProfileItem.ProfileItemMetadata))]
public partial class ProfileItem
{
internal class ProfileItemMetadata
{
private ProfileItemMetadata()
{
}
public string Description { get; set; }
[Key]
public int ItemID { get; set; }
[Include]
public ICollection<ProfileValue> ProfileValues { get; set; }
public string Type { get; set; }
}
}
Also, both ProfileItem, and Profile Value have CRUD methods exposing the respective entities to the client. For the time being, I'm just trying to get a query of profile values, to come to the client with their respective ProfileItem's. Calling db.ProfileValues.Include("ProfileItem") and doing ToList on this gives me both entities, it just seems that RIA is failing somewhere to include them.
I've looked at:
POCO entity-based RIA service can't de-serialize associated entities
exposing Associated entities in ria services
and even all the ones referenced here: Include() in EF4 using RIA Services Domain Service not loading!
Current Technologies:
Silverlight 5, Entity Framework 5 (DbContext, not ObjectContext), and Ria Services SP2
All and Any Ideas are welcome!
Edit Here is the RIA Service call:
[Query(IsDefault = true)]
public IQueryable<ProfileValue> GetProfileValues()
{
return db.ProfileValues.Include("ProfileItem");
}