I'm trying to do some customer filtering on a LLBLGenProDataSource2 without much luck. By "custom", I mean not using the SelectParameters collection.
I have a TextBox that will allow the user to enter some text, and then I want to filter my results using a FieldLikePredicate. My DS has LivePersistence disabled.
Here's my HTML:
<asp:TextBox ID="FilterText" runat="server"></asp:TextBox>
<asp:Button ID="Submit" runat="server" Text="Submit" />
<asp:GridView
ID="TestGridView" runat="server" DataSourceID="TestDS"
AllowPaging="true" DataKeyNames="ContractNumber"
PageSize="10">
<PagerSettings Mode="NextPreviousFirstLast" />
</asp:GridView>
<llblgenpro:LLBLGenProDataSource2 ID="TestDS" runat="server" EnablePaging="true" LivePersistence="false"
DataContainerType="EntityCollection"
AdapterTypeName="Components.DataAccessLayers.MyDatabase.DatabaseSpecific.DataAccessAdapter,
Components.DataAccessLayers.MyDatabaseDBSpecific"
EntityFactoryTypeName="Components.DataAccessLayers.MyDatabase.FactoryClasses.ContractMasterEntityFactory,
Components.DataAccessLayers.MyDatabase"
MaxNumberOfItemsToReturn="1000"
OnPerformSelect="TestDS_PerformSelect" OnPerformGetDbCount="TestDS_PerformGetDbCount"
>
</llblgenpro:LLBLGenProDataSource2>
Here is the code behind:
protected void TestDS_PerformSelect(object sender,
SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2 e)
{
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
//e.Filter == null, so I cannot add PredicateExpressions:
//e.Filter.PredicateExpression.Add(ContractMasterFields.SkuNumber % ("%" + FilterText.Text + "%"));
//e.Filter is also read-only so I cannot create a new instance:
//e.Filter = new RelationPredicateBucket();
adapter.FetchEntityCollection(e.ContainedCollection, e.Filter,
e.MaxNumberOfItemsToReturn, e.Sorter, e.PrefetchPath, e.PageNumber, e.PageSize);
}
}
protected void TestDS_PerformGetDbCount(object sender, PerformGetDbCountEventArgs2 e)
{
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
e.DbCount = adapter.GetDbCount(e.ContainedCollection, e.Filter);
}
}
So, my questions:
1) What is the best way to define custom filtering using the LLBLGenProDataSource2 control, with LivePersistence disabled?
2) If I should, instead, be using the SelectParameters collection for this, how do I define a FieldLikePredicate on the ControlParameter?
3) Or, am I going about this completely wrong, and should do something different that either of the above?
Thanks in advance.
Jerad