TypedLists and entity view

Posts   
 
    
Stevenn
User
Posts: 30
Joined: 26-Sep-2007
# Posted on: 14-Feb-2010 10:26:46   

Hi,

I need some advice, please.

I'm developing a .NET 2.0 project (client requirements). It is basically a watchdog that allows the user to view audit logs (in timed real-time). I'm using 2.6 and Adapter.

There are multiple servers, running a web service. How it should work: I have a typedlist that pulls the data from the related tables and slaps the info into a custom class. This is passed back to the client in a list<myClass> (it has to be non-llblgen client friendly, so no passing TypedList/Collection etc). The problem is, because the data is made up of fields from a TypedList, there is no way to make a client side Collection that can be added to, so that an EntityView will be updated.

In a non-typedlist scenario, I would have _mainEntityCollection and _newEntityCollection. I would then populate the _mainCollection with all the initial data, then update using AddRange(_newEntityCollection) on subsequent calls to the web service. This would then update the EntityView automatically on change.

One way I figured to get around this, would be to build a new table on the database consisting of all the fields I would require from the TypedList, then create collections of this pseudo-table on the client side, effectively tricking LLBLGen into acting like my TypedList was a collection.

This seems messy, not to mention it could become a maintenance nightmare down the line. Is there any other way to get around this?

Thanks

Steven

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Feb-2010 05:44:02   

I see some options here:

A. When the custom classes came back from the client, construct entity classes (or typedList rows) based on the custom data, then add them to the list (typeList or entitycollection).

B. Construct a DB view and then map it to a entity in LLBLGen Designer.

However, I'm not clear what is the real need here. What do you want to achieve in the final user form, on in your business level. For example, the custom classes sent from client would be "new", "edited", etc. (or if this is contextually managed by the method, MethodAdd, MethodEdit, etc). So understanding better this will make us propose a close solution.

David Elizondo | LLBLGen Support Team
Stevenn
User
Posts: 30
Joined: 26-Sep-2007
# Posted on: 15-Feb-2010 08:30:59   

Hi David,

i'll try to be a bit clearer. It's possible that the way i'm trying to accomplish this is totally misunderstood on my part...

daelmo wrote:

A. When the custom classes came back from the client, construct entity classes (or typedList rows) based on the custom data, then add them to the list (typeList or entitycollection).

The client app sits and monitors the servers for new messages via a web service. The web service pulls the data from the database in a TypedList. The data is then put into a List<myClass> of custom classes and sent to the client for display purposes. No editing takes place on the client, it is purely for monitoring. When the data arrives at the client app I want to put that data from my list of custom class into a 'Collection' so that i can apply a couple of EntityViews to that collection for displaying within listview controls on the client. Any new data in subsequent calls would then be added (AddRange(T)) to the existing 'collection' and the listvews would be updated.

Because the data is a combination of a number of tables (TypedList), i need the 'collection' to be a typed list, or some other solution, so that the entity view will pick up any new records as they are pulled from the server via the web service. The problem is, i can't create a TypedList row as the compiler complains about protected internal constructor so 'myTypedListRow newRow = new myTypedListRow()' fails. It appears that i can only add to proper Collections, or am i doing something wrong? I've been using SelfService up until now, so it is possible that i am not up to speed with the whole Adapter factory way of doing things.

daelmo wrote:

B. Construct a DB view and then map it to a entity in LLBLGen Designer.

I tried creating a view in the database and mapping to a TypedView in LLBLGen and doing the same thing, myTypedViewRow newRow = new myTypedViewRow(), but i get the same protected internal constructor error.

Both TypedList and TypedView have no Add() or AddRange() method either, so it would seem what i am trying to do is not possible. How would one go about doing what i am trying to do, except for making a psuedo-table on the database and generating a proper 'Collection' to fool LLBLGen into thinking that there is actually a collection like that?

Hope that is a bit clearer. Thanks for the help.

Steven

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 15-Feb-2010 10:22:09   

I'd say you use the sent structure, List<myClass>, since IList already has the AddRange() method. So you will be good to go.

Stevenn
User
Posts: 30
Joined: 26-Sep-2007
# Posted on: 15-Feb-2010 10:28:43   

Walaa wrote:

I'd say you use the sent structure, List<myClass>, since IList already has the AddRange() method. So you will be good to go.

But how do i attach an EntityView2 to that? I have a couple of controls on the client that display the data in the 'Collection' with different Filters and Sorts. So when the 'Collection' is updated in subsequent calls to the server, the EntityViews automatically get the new updates from one source and display them in the controls without me having to reapply sorts and filters to the collection.

Thanks

Steven

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 15-Feb-2010 11:06:08   

Well you are using EntityViews and EntityCollections while you don't have an Entity in the first place.

So either drop the usage of EntityViews and EntityCollections, and manually filter and sort the incoming List.

Or fake it, as said before you may create a dummy entity in the database which have the fileds you need. Then at the client side, you should convert the incoming List to a an EntityCollection of that dummy entity.

Stevenn
User
Posts: 30
Joined: 26-Sep-2007
# Posted on: 15-Feb-2010 11:13:01   

Thanks Walaa,

just thought there may be a cleaner way to do it, without faking the table.

Cheers

Steven