QueryInterceptor and Entity Framework code first
-
יום שלישי 27 מרץ 2012 14:07
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.
- נערך על-ידי _Kakone_ יום שלישי 27 מרץ 2012 14:09
כל התגובות
-
יום חמישי 29 מרץ 2012 07:56מנחה דיון
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.

- נערך על-ידי Alan_chenModerator יום חמישי 29 מרץ 2012 07:56
- סומן כתשובה על-ידי Alan_chenModerator יום שני 02 אפריל 2012 09:15
-
יום חמישי 29 מרץ 2012 10:28I 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...
-
יום שני 02 אפריל 2012 09:14מנחה דיון
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.
