The specified LINQ expression contains references to queries that are associated with different contexts.

Server Error in '/' Application.

The specified LINQ expression contains references to queries that are associated with different contexts.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The specified LINQ expression contains references to queries that are associated with different contexts.

Source Error:


Line 46:         if (objViewCONTENTBookingEventJoined == null || objViewCONTENTBookingEventJoined.Count == 0)
Line 47:         {
Line 48:             objViewCONTENTBookingEventJoined = CContentBookingEvent.Instance().fn_getContentBookingEventBySiteId(PublishSite.SiteID).ToList();
Line 49:             if (objViewCONTENTBookingEventJoined == null || objViewCONTENTBookingEventJoined.Count == 0)
Line 50:             {

Source File: c:\Project\Solution\ml\CMSWebParts\MLCustomWebParts\ComingEvent\NextEventCustomWebPart.ascx.cs    Line: 48

Stack Trace:


[NotSupportedException: The specified LINQ expression contains references to queries that are associated with different contexts.]
   System.Data.Objects.ELinq.FuncletizingVisitor.InlineObjectQuery(ObjectQuery inlineQuery, Type expressionType) +254
   System.Data.Objects.ELinq.FuncletizingVisitor.InlineValue(Expression expression, Boolean recompileOnChange) +323
   System.Data.Objects.ELinq.FuncletizingVisitor.Visit(Expression exp) +187
   System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m) +43
   System.Data.Objects.ELinq.FuncletizingVisitor.Visit(Expression exp) +499
   System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original) +167
   System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m) +76
   System.Data.Objects.ELinq.FuncletizingVisitor.Visit(Expression exp) +499
   System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original) +167
   System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m) +76
   System.Data.Objects.ELinq.FuncletizingVisitor.Visit(Expression exp) +499
   System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original) +167
   System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m) +76
   System.Data.Objects.ELinq.FuncletizingVisitor.Visit(Expression exp) +499
   System.Data.Objects.ELinq.Funcletizer.Funcletize(Expression expression, Func`1& recompileRequired) +213
   System.Data.Objects.ELinq.ELinqQueryState.CreateExpressionConverter() +173
   System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) +273
   System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +11120473
   System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +47
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +382
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +80
   ML.DAL.CContentBookingEvent.fn_getContentBookingEventBySiteId(Int32 SiteID) in C:\tfs\Release\ML.DAL\Implementation\CContentBookingEvent.cs:91
   CMSWebParts_MLCustomWebParts_ComingEvent_NextEventCustomWebPart.BindComingEventsDatalist(Int32 iSiteId) in c:\Project\Solution\ml\CMSWebParts\MLCustomWebParts\ComingEvent\NextEventCustomWebPart.ascx.cs:48
   CMSWebParts_MLCustomWebParts_ComingEvent_NextEventCustomWebPart.Page_Load(Object sender, EventArgs e) in c:\Project\Solution\ml\CMSWebParts\MLCustomWebParts\ComingEvent\NextEventCustomWebPart.ascx.cs:30
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   CMS.PortalControls.CMSAbstractWebPart.OnLoad(EventArgs e) +248
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272