Filtering Entiycollection with EntiyView!!

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 27-Aug-2005 18:47:18   

Greetings, In ADO.NET, data is stored in a DataTable object and can't be easily sorted or filtered. In many ways, a DataTable is much like the collection objects we deal with every day. If we want to sort or filter our data, we create a sorted / filtered DataView through which we can look at the data in the underlying DataTable. The DataView doesn't contain the data; it just gives us a sorted / filtered view at the DataTable. Similarly, the EntityCollection is LLBL's counterpart to the DataTable. Although LLBL's collection do provide us with powerful sorting capabilities, to filter the in-memory collection I would either write special code to handle the specific entity-type contained within the collection or go-back to the DB and re-fetch the objects as per my filter expression. In the UI, if I wanted to do conditional filtering for a comb-box the easiest way to do that is to refetch the collection from the DB with the new filter. If I could build an EntityView from the EntityCollection using the same predicate filter expression I would use to fetch the collection from the DB (DataView has its SQL property to do just that); then this would give the UI developer more choice how to handle such scenarios. I am not talking about object-caching here, but rather about the need to easily filter/sort an EnityCollection by deriving another more customized collection that reflects our view on the real object collection. Rocky goes this path in his article about creating sorted collections Msdn link And I find the idea very appealing. What do you think??

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 28-Aug-2005 20:21:38   

It looks like this is on the todo list, but doesn't have a date. Take a look at this thread to see if what they are suggesting would work for you. http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2872

Client side filtering requires a sort of 'view' object I think, plus if you want to do filtering, you need indexes. Adding entities and creating indexes is slow, so that's why they're not build in, as the indexes might never be used. They're on the todo list though, however there is no fixed date set when they'll be implemented.

omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 28-Aug-2005 22:51:57   

Thanks for the answer

arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 29-Aug-2005 15:49:27   

I also find the idea appealing. The filter engine is one of the hard parts isn't it? At a minimum, you would want to support syntax and capabilities similar to ado.net filtering. When I've talked to Frans about this in the past he alluded to needing provide a local copy of a sql query engine.

Sorting seems much easier.

omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 29-Aug-2005 19:38:34   

The idea of building a filtered bindable collection view from the in-memory collection is extremely useful in the UI. I think it would even make sense to use an SQL filter property to build the filtered view (just like DataViews and DataTables). Similarly, we can build a sorted view from the entityCollection by specifying the Field(s) to sort on and the sort-direction.

The idea is even more appealing for the LLBL community as it draws a complete parallelism with DataTable/DataView and as such all example code can be ported more naturally to LLBL's EntityCollection. I think that alone would prove very alluring for developers considering LLBL.

I hope Frans can push this feature to the top of his ToDo disappointed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 29-Aug-2005 21:09:47   

In 2.0 I'll add these. simple_smile For the 1.0 codebase, there wasn't enough time. They're on my list for 2.0, and I definitely will add them, to move the ITypedList implementation out of the entity collection into a some sort of view class. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
kapil
User
Posts: 10
Joined: 06-Sep-2005
# Posted on: 07-Sep-2005 08:05:19   

Hello,

I want all data to be fetched at once and place it on the server with additional BL which is MarshalByRefObject. From these data, i want selected data to be displayed and bind it to GUI controls.

In the UI, if I wanted to do conditional filtering for a comb-box the easiest way to do that is to refetch the collection from the DB with the new filter.

In my case, i am not updating database on every change so refetch data would be useless. Is there anyother way to display filtered data from EntiryCollection which is part of another Entity (FK - PK) ?

---now here is what i have tried ---- I tried assigning updated entity to the one in BL. This trick works for local object but if i acquire BL object from remote server, it just doesn't update. (Even don't throw errors!!!)

When i try removing an entity form EntityCollection (PK - FK), i get following error

System.InvalidCastException: Specified cast is not valid.
   at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2.RemoveAt(Int32 index)
   at BL.Estimate.saveProducts(ArrayList arrProducts) in c:\4estimate\bl\estimate.cs:line 98

Is there any way to use Entity/EntityCollection for .... - Remoting (MarshalByRefObject)/ singlton - With each entity having multiple EntityCollections (PK/FK) - Bind/Display customized filtered EntityCollection

BTW, i use Adapter with Firebird database.

Any idea would be highly appreciated.

Thanks,

Kapil

kapil
User
Posts: 10
Joined: 06-Sep-2005
# Posted on: 07-Sep-2005 08:31:08   

Hi,

I just noticed this thread after i posted. http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2872

I am happy to do filtering on serverside. But my problem still remains, even by walking through Collection, i can not update EntityCollection which is FK

Kapil

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 07-Sep-2005 10:32:23   

kapil wrote:

Hello,

I want all data to be fetched at once and place it on the server with additional BL which is MarshalByRefObject. From these data, i want selected data to be displayed and bind it to GUI controls.

In the UI, if I wanted to do conditional filtering for a comb-box the easiest way to do that is to refetch the collection from the DB with the new filter.

In my case, i am not updating database on every change so refetch data would be useless. Is there anyother way to display filtered data from EntiryCollection which is part of another Entity (FK - PK) ?

---now here is what i have tried ---- I tried assigning updated entity to the one in BL. This trick works for local object but if i acquire BL object from remote server, it just doesn't update. (Even don't throw errors!!!)

When i try removing an entity form EntityCollection (PK - FK), i get following error

System.InvalidCastException: Specified cast is not valid.
   at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2.RemoveAt(Int32 index)
   at BL.Estimate.saveProducts(ArrayList arrProducts) in c:\4estimate\bl\estimate.cs:line 98

Is there any way to use Entity/EntityCollection for .... - Remoting (MarshalByRefObject)/ singlton

No, they have to be passed by value: MarshalByValueObject

  • With each entity having multiple EntityCollections (PK/FK)
  • Bind/Display customized filtered EntityCollection

That will work.

Also consider fields mapped onto related fields in the designer, so you can map Customer.CompanyName in Order for example, so you can bind a collection of Order objects to a grid and have a CompanyName column, which actually reflects the order.Customer.Companyname

Frans Bouma | Lead developer LLBLGen Pro
tolga
User
Posts: 25
Joined: 26-Feb-2006
# Posted on: 01-Mar-2006 00:22:46   

I am seeing that if I change order.Customer to a different customer (which matches the new order.CustomerID value), the order.Customer.Companyname property momentarily reflects the correct new value but then reverts back to the old value when a new field is focused in the winform GUI.

Any idea why?

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 01-Mar-2006 15:28:32   

tolga, Would you please elaborate more on the issue? What exactly are you trying to do? And it would be much of a help if you posted code snippets.

Thanks and good luck

tolga
User
Posts: 25
Joined: 26-Feb-2006
# Posted on: 03-Mar-2006 00:07:14   

I posted a new message on its own thread conyaining some code.

Thanks