Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Linq to entities - what is wrong here.
Message
General information
Forum:
ASP.NET
Category:
Silverlight
Miscellaneous
Thread ID:
01524523
Message ID:
01524610
Views:
55
>OK. I have a silverlight 4 app. EF datamodel of my SQL database. Domain DataService making my Entities visible.
>
>Two entity tables are Projects and Change_Requests. Projects has primary key Project_ID. Change Requests has FK Product_ID. Change Requests have a SubdivisionID (int) field.
>Now I'm trying to do the equivalent of a join or subquery to get Projects that have Change_Requests in a specific Change_Request.SubdivisionID.
>
>I've tried..
>EntityQuery<Project> query = (from p in _Context.Projects
>                                          from c in _Context.Change_Requests
>                                          where p.Project_ID == c.Project_ID && c.Subdivision == SubdivisionID
>                                          select p);
>I get an error ..
>Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<ChangeManagement.Web.Project>' to 'System.ServiceModel.DomainServices.Client.EntityQuery<ChangeManagement.Web.Project>'
>How do I get by this?

I was going to suggest that you moved this to the Service side but I see elswhere that you have now done that. Just wanted to point out that since you (presumably) have the association between Project and Change_Requests defined in EF you should be able to simplify to something like this:
public IQueryable<Project> GetProjForSubDiv(int SubDivisionId)
        {
            return (from c in ObjectContext.Change_Requests where c.SubDivision == SubDivisionId select c.Project);
        }
and client side becomes something like:
           EntityQuery<Project> query = _Context.GetProjForSubDivQuery(12345);
            _Context.Load<Project>(query).Completed += (loadOp, args) =>
                {
                    var x = ((LoadOperation)loadOp).Entities;
                    //or whatever....
                };
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform