This is a migrated thread and some comments may be shown as answers.

Basic one to many retrieval

1 Answer 56 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mark
Top achievements
Rank 1
Mark asked on 20 Feb 2012, 01:26 AM
Apologies if this has been answered before or seems trivial, but I can't seem to get it to work.  I tried reading the docs and search also with nothing yet, but some confusing tidbits about FetchPlans and IsManaged and the like.  I haven't seen a single step-by-step for what seems like a common task.

Basically in EF 4 using WCF RIA for a Silverlight app, it defines 1:many relationships as an EntityCollection in metadata and if you add an [Include] plus an .Include() statement in the domain service retrieval query it pulls down this info.
eg:


[MetadataTypeAttribute(typeof(Clinic.ClinicMetadata))]
public partial class Clinic
{
        [Include]
        public EntityCollection<Location> Locations { get; set; }
    ...
}
and in the domain service:

public IQueryable<Clinic> GetClinics()
{
       return DataContext.Clinics
            .Include("Locations");
}
and this works great. How do I do this in OpenAccess?? I tried setting the IsManaged property to true in the .rlinq file for the relation, and a metadata attribute, but it doesn't like the [Include]. What else do I need to do to make this just work and also reference in the Silverlight code as clinic.Locations?

1 Answer, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 22 Feb 2012, 05:39 PM
Hello Mark,

You will need to add the association attribute as well. That will instruct our code generation to generate the required collection on your client side. Here is an example on how to do so:
[MetadataTypeAttribute(typeof(EmployeeTerritory.EmployeeTerritoryMetadata))]
public partial class EmployeeTerritory
{
internal sealed class EmployeeTerritoryMetadata
{
 [Include]
 [Association("Territory", "TerritoryID", "TerritoryD")]
 public Territory Territory { get; set; }
}
}


Regards,
Petar
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Tags
Getting Started
Asked by
Mark
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Share this question
or