LLB v2.6 Final 2.6.10.930
Adapter template
Using an LLBLGenProDataSource2 with LivePersistence="false", I am trying to fill the ContainedCollection in the PerformSelect handler:
protected void LLBLGenProDataSource21_PerformSelect(object sender, PerformSelectEventArgs2 e)
{
var q = CreateLinq().TakePage(e.PageNumber, e.PageSize);
var regulationTextEntities = ((ILLBLGenProQuery) q).Execute<EntityCollection<RegulationTextEntity>>();
e.ContainedCollection.AddRange(regulationTextEntities);
}
I get the following exception:
c isn't of the right type
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.ArgumentException: c isn't of the right type
Source Error:
Line 78: var q = CreateLinq().TakePage(e.PageNumber, e.PageSize);
Line 79: var regulationTextEntities = ((ILLBLGenProQuery) q).Execute<EntityCollection<RegulationTextEntity>>();
Line 80: e.ContainedCollection.AddRange(regulationTextEntities);
Line 81: }
Line 82:
Source File: D:\Work\DevExpressExample\DevExpressExample.Module\CustomPropertyExample.aspx.cs Line: 80
Stack Trace:
[ArgumentException: c isn't of the right type]
SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2`1.SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection2.AddRange(IEntityCollection2 c) +114
Examples.DevExpressExample.Module.CustomPropertyExample.LLBLGenProDataSource21_PerformSelect(Object sender, PerformSelectEventArgs2 e) in D:\Work\DevExpressExample\DevExpressExample.Module\CustomPropertyExample.aspx.cs:80
SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource2.OnPerformSelect(PerformSelectEventArgs2 eventArgs) +22
SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteSelectEntityCollection(Int32 pageSize, Int32 pageNumber, DataSourceSelectArguments arguments) +630
SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteSelect(DataSourceSelectArguments arguments) +181
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +19
DevExpress.Web.ASPxClasses.Internal.DataHelper.PerformSelect() +203
DevExpress.Web.ASPxGridView.GridViewDataHelper.PerformSelect() +173
DevExpress.Web.ASPxClasses.Internal.DataContainer.PerformSelect() +123
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBindCore() +44
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBind() +177
DevExpress.Web.ASPxGridView.ASPxGridView.DataBind() +225
DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound(Boolean ensureChildControls) +114
DevExpress.Web.ASPxClasses.Internal.DataHelperBase.EnsureDataBound() +34
DevExpress.Web.ASPxClasses.Internal.DataContainer.EnsureDataBound() +126
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.OnPreRender(EventArgs e) +47
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955
If I reference the data source by its private name, it works:
protected void LLBLGenProDataSource21_PerformSelect(object sender, PerformSelectEventArgs2 e)
{
var q = CreateLinq().TakePage(e.PageNumber, e.PageSize);
var regulationTextEntities = ((ILLBLGenProQuery) q).Execute<EntityCollection<RegulationTextEntity>>();
LLBLGenProDataSource21.EntityCollection = regulationTextEntities;
}
I am confused by this as in Intellisense, it all looks correct. The .AddRange needs an IEntityCollection2 and I am passing one.
Could it be that I am passing an EntityCollection<T> which ContainedCollection doesn't like?
Is there a downside to using the LLBLGenProDataSource21.EntityCollection approach that will bite me later?