Print Page | Close Window

Server Query Filtering

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1331
Printed Date: 29-Apr-2025 at 12:27pm


Topic: Server Query Filtering
Posted By: heyyou
Subject: Server Query Filtering
Date Posted: 16-Jun-2009 at 6:50pm
Hi
 
According to the examples I've seen, if I am implementing the IEntityServerFetching interface, the following code should be correct, however, I get a compile time error
 
var query = args.Query as EntityQuery<Client>;
query.Filter((IQueryable<Client> cl) => cl.Where(fc => fc.DeleteDate == null));
 
with the error being
Error 19 The type 'MyApp.Web.Client' cannot be used as type parameter 'T2' in the generic type or method 'IdeaBlade.EntityModel.EntityQueryExtensions.Filter<T1,T2>(IdeaBlade.EntityModel.EntityQuery<T1>, System.Func<System.Linq.IQueryable<T2>,System.Linq.IQueryable<T2>>)'. There is no implicit reference conversion from 'MyApp.Web.Client' to 'IdeaBlade.EntityModel.Entity'. 
 
Client is one of the entities mapped in the Object mapper
 
Can anyone suggest to me what is not correct here?
 
Regards
Stuart
 
 



Replies:
Posted By: kimj
Date Posted: 17-Jun-2009 at 8:18pm

The only thing I can think of is that there might be a mixup with the Entity Model class of the same name.  I'd double check all references and make sure the assembly holding the domain model builds OK (unless of course it's the same assembly which is failing here).

You'll get a runtime error with the above code, however.  The ServerEntityQuery passed into the method cannot be cast to an EntityQuery<T>; so just cast to an EntityQuery before applying the filter.
 


Posted By: jsobell
Date Posted: 18-Jun-2009 at 6:15am
Thanks Kim,
The problem was that the default namespace contained the MS generated entities as well as IdeaBlade's, so it was grabbing the wrong ones by default.

Cheers,
  Jason



Print Page | Close Window