Simple to persist updated gridview data, but...

Posts   
 
    
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 07-Jun-2006 13:39:18   

Hi,

From my Presentation layer, how do I persist entitycollection data updated in my grid, via my Business layer?

I'm can easily call a method in my BL to populate the grid, as in:

    Dim Divisions As New DivisionManager
    BindingSource1.DataSource = Divisions.GetAllDivisions

but I can't find out how to pass back the updated collection from my grid to my BL to persist it as in adapter.SaveEntityCollection(gridDivisions) ?

I'm using version 1.0.2005.1/Adapter/VS2005/VB. I've looked closely at the docs and its driving me nuts. Seems simple confused , so where am I going wrong?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jun-2006 14:01:12   

Read the data back from the grid, construct an entitycollection, fill it with the dataread, then pass it to the business layer.

Please refer to the following thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4968

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 07-Jun-2006 14:53:38   

Walaa,

Read the data back from the grid, construct an entitycollection, fill it with the dataread, then pass it to the business layer.

Please refer to the following thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4968

Ahhh, this is also necessary in my WinForm (not Web) client? flushed

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jun-2006 15:37:08   

What's wrong with the approach you followed here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5979

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 07-Jun-2006 16:36:24   

Walaa wrote:

What's wrong with the approach you followed here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5979

I switched from Self-service to Adapter as it seemed to be more appropriate for my scenario of Win + Web Clients in various part of the world, but the learning curve is pretty steepdisappointed

I've created a Presentation Layer linked to managers in a BL, linked to my DAL. While it was straightforward to pass my DivisionEntityCollection up to my grid, I was surprised at how awkward it is to pass the updated collection back. disappointed

Since the grid is able to display the data, I'm a little shell shocked that its necessary to read the collection out of the grid instead of just picking up a reference to it. Maybe I've got this wrong.

Any other thoughts gratefully received.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 07-Jun-2006 17:08:24   

Why can't you cast the grid's datasource property's value to IEntityCollection and pass it to your BL? (or cast it to IEntityCollection2 and pass it to the adapter)

You could also store the reference to the collection in a membervariable,...

Frans Bouma | Lead developer LLBLGen Pro
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 07-Jun-2006 23:39:11   

Otis wrote:

Why can't you cast the grid's datasource property's value to IEntityCollection and pass it to your BL? (or cast it to IEntityCollection2 and pass it to the adapter)

simple_smile Changes in the grid were successfully persisted when I cast as follows:

    Dim Divisions As New DivisionManager
    Divisions.SaveDivisions(CType(BindingSource1.DataSource(), EntityCollection))

But rage whenever I access a method in DivisionManager that instantiates a DataAccessAdapter (eg. Dim adapter As New DataAccessAdapter() ), Debug shows the following exception:

A first chance exception of type 'System.InvalidOperationException' occurred in System.dll

Any ideas?

Finally, is there another source of information that would have provided information about casting the Grid's data source property and avoided me asking the original question?

Thanks in advance, you've already been a great help.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-Jun-2006 06:31:05   

whenever I access a method in DivisionManager that instantiates a DataAccessAdapter (eg. Dim adapter As New DataAccessAdapter() ), Debug shows the following exception:

A first chance exception of type 'System.InvalidOperationException' occurred in System.dll

Any ideas?

Please check the following threaad (which might be relevant to your issue): http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5383

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 08-Jun-2006 14:36:26   

[quotenick="Walaa"]

Please check the following threaad (which might be relevant to your issue): http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5383

It was, and it did simple_smile

Much obliged!