开发者

WCF Data Services & EF 4.1 RC Code First - Overrode CreateDataSource, now how to use CurrentDataSource?

I'm creating a WCF Data Services (OData) with EF 4.1 RC Code First. I've overrode the CreateDataSource method to make it work, but then I can't create operations that return an IQueryable or using CurrentDataSource. Is there a way to map CurrentDataSource property back to DbContext?

Here's my code:

protected override ObjectContext CreateDataSource()
{
    var context = ((IObjectContextAdapter)new NotesnhacContext()).ObjectContext;
    context.ContextOptions.ProxyCreationEnabled = false;

    return context;
}

[WebGet]
public IQueryable<MusicSheet> GetMusicSheets(int pageIndex, int pageSize)
{开发者_如何学C
    // This doesn't work... I can't access "MusicSheets"
    //return CurrentDataSource.MusicSheets.Where(... ... );
}

Thanks.


Can you try the new CTP of WCF Data Services - http://blogs.msdn.com/b/astoriateam/archive/2011/03/09/announcing-wcf-data-services-march-2011-ctp2-for-net4-amp-sl4.aspx

With this CTP, one no longer needs to override the CreateDataSource method, and the CurrentDataSource is an instance of DBContext.

In other words, DbContext is fully supported in this CTP.

Hope this helps.

Thanks Pratik

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜