QueryInterceptor and Entity Framework code first
-
Tuesday, March 27, 2012 2:07 PM
Hello,
I want to do a query in my QueryInterceptor method. This is a stupid sample that works well :
public class WcfDataService : DataService<MyDbContext> { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetPageSize("*", 100); config.SetEntitySetAccessRule("Interventions", EntitySetRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3; } [QueryInterceptor("Interventions")] public Expression<Func<Intervention, bool>> OnQueryInterventions() { var inter = ((IObjectContextAdapter)CurrentDataSource).ObjectContext.CreateObjectSet<Intervention>(); return (i => inter.Any(j => j.Object.StartsWith("changement") && i.Id == j.Id)); } }But, if I replace the line :
var inter = ((IObjectContextAdapter)CurrentDataSource).ObjectContext.CreateObjectSet<Intervention>();
by
var inter = CurrentDataSource.Set<Intervention>();
it doesn't work. Why does it work with ObjectSet and not with DbSet ?
Cordially,
Kakone.
- Edited by _Kakone_ Tuesday, March 27, 2012 2:09 PM
All Replies
-
Thursday, March 29, 2012 7:56 AMModerator
Hi Kakone,
Welcome!
The question has been discussed : http://qa.social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/a7b26c30-e32d-4324-90cb-e90c7141fd49
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Edited by Alan_chenModerator Thursday, March 29, 2012 7:56 AM
- Marked As Answer by Alan_chenModerator Monday, April 02, 2012 9:15 AM
-
Thursday, March 29, 2012 10:28 AMI use the WCF Data Services Oct 2011 CTP. In this CTP, the DataService class supports the DbContext directly (in theory). I hope it's just a bug...
-
Monday, April 02, 2012 9:14 AMModerator
Hi Kakone,
Yes, it is a known issue and it will be updated in next version, thanks for understanding.
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.


