ScalarQueryExpression for LLBLGen 1.0

Posts   
 
    
sami
User
Posts: 93
Joined: 28-Oct-2005
# Posted on: 22-Jun-2006 13:25:56   

I just noticed following in 2.0 features

DDED: RUNTIME LIBRARIES: ScalarQueryExpression class to specify scalar subqueries in expressions and for example in select lists.

If I ask really really nicely, would it be possible to get this feature to 1.0 too? This is something I really need there. Or is there any workaround to get samekind of functionality?

Howabout getting these kind of data for entities too? For example, customer entity which has a property ordercount, without storing the ordercount to customer -table.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 22-Jun-2006 13:48:57   

sami wrote:

I just noticed following in 2.0 features

DDED: RUNTIME LIBRARIES: ScalarQueryExpression class to specify scalar subqueries in expressions and for example in select lists.

If I ask really really nicely, would it be possible to get this feature to 1.0 too? This is something I really need there. Or is there any workaround to get samekind of functionality?

It's really an IExpression implementation. As the ToQueryText, it produces a subquery. The hard part is to get the persistence info added to it in the DataAccessAdapter, so you have to alter the DataAccessAdapter template a bit.

I'm not going to backport features to 1.0, as no new features will be added to 1.0, just to 2.0. 1.0 will only get bugfixes if a fix is needed.

Howabout getting these kind of data for entities too? For example, customer entity which has a property ordercount, without storing the ordercount to customer -table.

See: http://weblogs.asp.net/fbouma/archive/2006/06/09/LLBLGen-Pro-v2.0-with-ASP.NET-2.0.aspx simple_smile

Frans Bouma | Lead developer LLBLGen Pro
sami
User
Posts: 93
Joined: 28-Oct-2005
# Posted on: 22-Jun-2006 14:07:01   

drool Cool article, cool stuff! sunglasses

Anyway, I suppose the the step 6 can be done with 1.0 version too, just extend the factory as in your sample?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 22-Jun-2006 16:12:54   

sami wrote:

drool Cool article, cool stuff! sunglasses

smile

Anyway, I suppose the the step 6 can be done with 1.0 version too, just extend the factory as in your sample?

Yes, as long as the ScalarQueryExpression is available of course. I haven't tried it in 1.0 though, but I don't think you'll run into problems.

One thing to think about is concepts: by adding a field like this to an entity, it's not strictly speaking an entity anymore as in: this is the entity and it's mapped onto this table. You're then dealing with an entity which is mapped onto a resultset, which in theory is again an entity, but not in the sense that it has a physical representation in the form of a table/view definition. So for these things I'd go for a dynamiclist or view.

Frans Bouma | Lead developer LLBLGen Pro
sami
User
Posts: 93
Joined: 28-Oct-2005
# Posted on: 22-Jun-2006 16:48:25   

Thing is, I want to use it as an entity becouse I want to be able to save it too without a server round trip. I don't fancy to use readonlylist to get the entitydata with the count and then fetch the entity when I want to save the entity data.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 22-Jun-2006 17:15:34   

ah I see simple_smile . I haven't tried it in a save scenario though, however as the field is an expression and not settable, it won't change value and therefore won't end up in a query. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
DarinSh
User
Posts: 9
Joined: 25-Feb-2007
# Posted on: 28-Jun-2007 07:26:53   

Could one of you guys give me a pointer or 2 on how to implement this for version 1? Here's the scenario.. I have a customer who has orders. I want to get the count for the orders (grouped by customer). Thats easy, I just set an aggragate function to count the rows, grouped by customer. What I cant figure out how to do is get another field in the resultset which is a count of all the orders for a customer that are still open. Basically, in sql I would just need a sub query.

It seems that the scalarQueryExpression is great for this, but you said it's also possible in v1. Any sample code?

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 28-Jun-2007 09:41:57   

Do you want to fetch this scalar value alone or within another context? It would be better if you post the entire SQL query that you want to execute.