How to access to the EF Context object

16 views
Skip to first unread message

Davo

unread,
Dec 8, 2010, 9:56:44 PM12/8/10
to ncommon
I am using NCommon with Entity framework but I have a specific case
where I need to call ExecuteStoreQuery on the context object.


using (var context = new ArticleContext(connectionString))
{
var rows =
context.ExecuteStoreQuery<ArticleSearchView>(sql).AsQueryable();

Print(rows.ToList());
}


Is there a way of accessing this object?

Ritesh Rao

unread,
Dec 9, 2010, 9:20:49 AM12/9/10
to nco...@googlegroups.com
Try this:

using (var scope = new UnitOfWorkScope())
{
    var curentUOW = scope.CurrentUnitOfWork<EFUnitOfWork>();
    var currentSession = curentUOW.GetSession<ArticleSearchView>();
    var rows = currentSession.Context.ExecuteStoreQuery<ArticleSearchView>(sql).AsQueryable();
}



--
You received this message because you are subscribed to the Google Groups "ncommon" group.
To post to this group, send email to nco...@googlegroups.com.
To unsubscribe from this group, send email to ncommon+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ncommon?hl=en.


Reply all
Reply to author
Forward
0 new messages