ObjectDataSource CHALLENGE!

Posts   
 
    
Ren
User
Posts: 42
Joined: 01-Jul-2005
# Posted on: 06-Jan-2006 20:02:00   

A question that I have been posting on asp.net has been...

Is there any way to use the same select method for both the SelectMethod and SelectCountMethod when paging is enabled with the ObjectDataSource?

You would think there has to be a way to do this. Can I pass a select parameter by reference that returns a count? Or if I am returning a collection, have one of the properties of the collection be a TotalCount property and somehow use that?

I don't like the idea of having to create a 2nd companion method for each select method that takes the same parameters. Actually that is pretty weak if I am forced to do that. I guess you could overload a GetCount method but that would require having rather generic parameters being passed in like "ID" instead of "customerID". I'd really rather not do that though.

-- a member of the ASP.NET team had this answer for my question-------------------------------

If you want to use the ObjectDataSource EnablePaging=true feature, you will need to define a separate SelectCountMethod for the select operation. <snip>

We did consider a design pattern where the Select method included an output parameter for the total count, but decided against this pattern, because you typically only want to return the total row count on the first request for data, and not subsequent requests. A single method would have meant that the total count is always calculated, even when it is not needed or used. <snip>


I am sad to see that they didn't continue with the 2nd idea, as more and more users start adopting the ObjectDataSource, they will soon realize the above. It's not difficult to add logic to the select method to check if the totalCount != 0, if so then just pass the value back and not re-query the database..

If anyone has thoughts on how to have the SelectCountMethod and SelectMethod use the same Method that would be awesome. I've been racking my brain trying to figure out a way of doing this without diving deep into the objectdatasource. You would really be helping a brother out!

Winner gets a prize.. an "atta boy" or "atta girl" smile

pilotboba
User
Posts: 434
Joined: 05-Aug-2005
# Posted on: 06-Jan-2006 22:45:33   

Ren wrote:

If anyone has thoughts on how to have the SelectCountMethod and SelectMethod use the same Method that would be awesome. I've been racking my brain trying to figure out a way of doing this without diving deep into the objectdatasource. You would really be helping a brother out!

Can you derive from the ObjectDataSource to create MyObjectDataSource and have the SelectCountMethod call the SelectMethod? Then use MyObjectDataSource?

BOb

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 07-Jan-2006 10:16:52   

Be aware that the objectdatasource is broken. It always re-creates a NEW instance and updates the postback-data in that one, so change-tracking is LOST.

Frans Bouma | Lead developer LLBLGen Pro
mdissel
User
Posts: 92
Joined: 16-Sep-2003
# Posted on: 08-Jan-2006 16:06:39   

Otis wrote:

Be aware that the objectdatasource is broken. It always re-creates a NEW instance and updates the postback-data in that one, so change-tracking is LOST.

Are you going to add support for an ObjectDataSource into the next LLBLgen version? i didn't test it yet, but if the default objectdatasource is broken, we (or you wink build it ourselves..

Thanks

Marco

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 08-Jan-2006 16:47:51   

mdissel wrote:

Otis wrote:

Be aware that the objectdatasource is broken. It always re-creates a NEW instance and updates the postback-data in that one, so change-tracking is LOST.

Are you going to add support for an ObjectDataSource into the next LLBLgen version? i didn't test it yet, but if the default objectdatasource is broken, we (or you wink build it ourselves..

Thanks Marco

Yes we will, (LLBLGenProDataSource wink )

Frans Bouma | Lead developer LLBLGen Pro
mdissel
User
Posts: 92
Joined: 16-Sep-2003
# Posted on: 08-Jan-2006 17:01:00   

And you're going to build that on on top of IDataSource?

Thanks

Marco

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 08-Jan-2006 19:07:33   

mdissel wrote:

And you're going to build that on on top of IDataSource?

As a derived class from DataSourceControl simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Ren
User
Posts: 42
Joined: 01-Jul-2005
# Posted on: 09-Jan-2006 17:55:19   

Whoa.. good to know. When can we expect the next version of LLBL Gen with this?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 09-Jan-2006 18:51:09   

Ren wrote:

Whoa.. good to know. When can we expect the next version of LLBL Gen with this?

I hope to start the beta at the end of march. simple_smile

Frans Bouma | Lead developer LLBLGen Pro