Print Page | Close Window

Problems querying associations

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1895
Printed Date: 21-Apr-2026 at 12:19pm


Topic: Problems querying associations
Posted By: jmarbutt
Subject: Problems querying associations
Date Posted: 14-Jun-2010 at 7:30am
I have tried the following 2 queries and get the same error:

   var query = from c in Context.Closings
                        where c.UserClosings.FirstOrDefault().UserId == CurrentUser.Id
                        select c;
            
            query.ExecuteAsync(op => op.Results.ForEach(Closings.Add));

            var query2 = from uc in Context.UserClosings
                         where uc.UserId == CurrentUser.Id
                         select uc;
            query2 = query2.Include("Closing");
            var op2 = query2.ExecuteAsync();


--------

The error I get is:

Value is not compatible with property: Id DataType: System.Int32


I have checked my model and my data and they both look good. Any other ideas?





Replies:
Posted By: kimj
Date Posted: 16-Jun-2010 at 10:19am
A property value compatibility check can be triggered as an object graph is materialized during a query.  The property it's complaining about could be on Closing, UserClosing, or even another type accessed via a navigation property on one of these types.  The likely trigger is logic in an entity constructor - so check these; and also if you've overridden any UpdateNullEntity methods in your entities. 
 
If neither of the above looks like the culprit, please send us your EDMX.



Print Page | Close Window