- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
Are there any Linq to LLBLGen Pro Samples/Examples
Joined: 25-Oct-2005
Is there any Linq to LLBLGen Pro Sample/Example code available?
In the Forum description it says 'please check the examples shipped with LLBLGen Pro' Maybe I'm being a bit dense but the only example code I could find is code snippets in the help file.
I've looked here but no joy: http://www.llblgen.com/pages/examples.aspx
Regards Jeremy
There is Unit Tests code shipped with LLBLGen Pro v.2.6 Which can be found at: <LLBLGen Pro v2.6 installation folder>\Sourcecode\LinqUnitTests
This is not available if you are using the demo version, we'll make them public for such cases.
The Additional downloads page on the main site now contains the archive with a subset of our unittests (C#, for adapter and selfservicing) for linq to llblgen pro, so you can use them as example queries
Joined: 25-Oct-2005
Thanks Frans, though I just looked in the demo install directory and those unit test are already there!
And also just saw they ARE mentioned in the help file section 'Generated code - Linq to LLBLGen Pro, getting started'
While it’s useful to have those unit tests I was after a runable application sample.
To that end Joseph Chancellor has agreed to let me put the code from his Rapid C# Windows Development book on codeplex. I think its a decent starting point for evaluating Linq to LLBLGen (and maybe Linq to SQL if I get keen). So I intend to upgrade it to the current llblgen version and then redo the queries in Linq and see how I go.
As background we’re about to embark on a new project against an existing database and obviously we would like to use an ORM but we have a strong preference for doing the queries with Linq rather than using the ORM’s API. We’re a bit nervous about version 1 of Microsoft’s offerings so here I am.
TomDog wrote:
Thanks Frans, though I just looked in the demo install directory and those unit test are already there!
haha
That's a great blunder
. Ok, I overlooked that in the installer. So it's indeed a bit silly to have the example archive up, but I guess twice is better than never
While it’s useful to have those unit tests I was after a runable application sample.
I think any example we have on the site (in the Examples section) is good to understand what to do with an O/R mapper, and you can replace any query written in such example with a linq query, our linq provider is designed to be an alternative for any query through our native system. Writing a query is just a small part of using an O/R mapper system like LLBLGen Pro.
To that end Joseph Chancellor has agreed to let me put the code from his Rapid C# Windows Development book on codeplex. I think its a decent starting point for evaluating Linq to LLBLGen (and maybe Linq to SQL if I get keen). So I intend to upgrade it to the current llblgen version and then redo the queries in Linq and see how I go.
Cool! Btw, Joseph is back from China (I believe he went there a couple of years ago)?
Haven't heard from him in a while. He's a great author.
Joined: 25-Oct-2005
I think any example we have on the site (in the Examples section) is good to understand what to do with an O/R mapper, and you can replace any query written in such example with a linq query, our linq provider is designed to be an alternative for any query through our native system. Writing a query is just a small part of using an O/R mapper system like LLBLGen Pro
Sure but I guess we are prepared to take it as given that the other parts of LLBLGen work as advertised.
AFAICT none of your examples have an enquiry/search screen similar to this: http://www.codeproject.com/KB/linq/LINQDynamicPredicate.aspx while Joseph’s code does. frmOrderSearch -> SalesOrderHeaderEntity.GetSalesOrderHeaderCollection
We have a particular interest in this as our existing Access front end has a rather nasty enquiry/search screen with four tab pages of criteria which I have reproduced in winforms and am using in my evaluation of whatever data access strategy we go with.
btw Project is up: http://www.codeplex.com/RapidDevBookCode
TomDog wrote:
I think any example we have on the site (in the Examples section) is good to understand what to do with an O/R mapper, and you can replace any query written in such example with a linq query, our linq provider is designed to be an alternative for any query through our native system. Writing a query is just a small part of using an O/R mapper system like LLBLGen Pro
Sure but I guess we are prepared to take it as given that the other parts of LLBLGen work as advertised.
AFAICT none of your examples have an enquiry/search screen similar to this: http://www.codeproject.com/KB/linq/LINQDynamicPredicate.aspx while Joseph’s code does. frmOrderSearch -> SalesOrderHeaderEntity.GetSalesOrderHeaderCollection
Correct, though that's not a tough thing to do: just a set of if statements and appending predicates to the main filter. With linq it's a bit of a struggle as you'll appending WHERE calls to the main query which might turn out to be less optimal (due to Linq's design, not our provider).
See for an example here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14131
With our native api it's very easy as you can simply add predicate instances to a predicate expression and use that as the filter for the query. As it's field based, you can also build field selectors (combo boxes for example) which enlist the fields present (using the entity field index enums) and which are used to build FieldCompareValue predicates for example. You can't do that with linq.
Don't fall into the trap that it might be possible to do so with Linq, using a fancy predicate builder. That one runs in-memory. if you want to have a db filter with linq, you have to have the field / property you're filtering on in the expression tree, OR you've to go through the unpleasant route of building Expression based subtrees with memberinfo's using reflection. This is doable, but way more code than our native api constructs.
I built something a long time ago, the thread is still visible, but the code is a little outdated I think, as it's written against v1. http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=1464&ThreadID=332
btw Project is up: http://www.codeplex.com/RapidDevBookCode
Thanks! I'll see if I can have a go at it and help you out porting the stuff.
Joined: 25-Oct-2005
Otis wrote:
Correct, though that's not a tough thing to do: just a set of if statements and appending predicates to the main filter. With linq it's a bit of a struggle as you'll appending WHERE calls to the main query which might turn out to be less optimal (due to Linq's design, not our provider).
See for an example here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14131
As I suspected I’m not the only one world trying to do this which makes it odd that there’s stuff-all run able Linq examples(with GUI) of how to do something like that which, I would have thought, just about everyone would need to do.
When you say ‘less optimal’ your not referring to the generated SQL are you?
Otis wrote:
Don't fall into the trap that it might be possible to do so with Linq, using a fancy predicate builder. That one runs in-memory. if you want to have a db filter with linq, you have to have the field / property you're filtering on in the expression tree, OR you've to go through the unpleasant route of building Expression based subtrees with memberinfo's using reflection. This is doable, but way more code than our native api constructs.
Yes I read your response in http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=1395 : are you sure predicatebuilder does not do a db filter? when a ran http://www.codeproject.com/KB/linq/LINQDynamicPredicate.aspx and viewed the SQL in the debugger it had the filters I has selected as where clause’s. Though as one of the messages on the article said as he was just ANDing he could have used query = query.where
Otis wrote:
I built something a long time ago, the thread is still visible, but the code is a little outdated I think, as it's written against v1. http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=1464&ThreadID=332
Ah the old ‘I wish I could give my end-users reporting against the object model’ I’ve come across something that looks similar to your screenshot for linq to sql http://blogs.msdn.com/vbteam/archive/2007/08/29/implementing-dynamic-searching-using-linq.aspx There is this as well http://www.codeplex.com/linqextensions - but it has a commandline example only
But AFAIK I don’t need to go that far –i.e. I don’t need to dynamically create predicates just dynamically include/exclude and combine static predicates and to make matters even simpler I think I’ll only ever need to AND them so query = query.where will probably cut it. Still, it gets a bit nasty with joins and filtering on fields that aren't returned.
Otis wrote:
btw Project is up: http://www.codeplex.com/RapidDevBookCode
Thanks! I'll see if I can have a go at it and help you out porting the stuff.
I was hoping you'd say that. That would be awesome if you could
– I can add you to the project as a Developer if you would like.
TomDog wrote:
Otis wrote:
Correct, though that's not a tough thing to do: just a set of if statements and appending predicates to the main filter. With linq it's a bit of a struggle as you'll appending WHERE calls to the main query which might turn out to be less optimal (due to Linq's design, not our provider).
See for an example here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14131
As I suspected I’m not the only one world trying to do this which makes it odd that there’s stuff-all run able Linq examples(with GUI) of how to do something like that which, I would have thought, just about everyone would need to do.
When you say ‘less optimal’ your not referring to the generated SQL are you?
Yes to the generated sql.
I'm not really following you why you would need UI's etc. to understand how linq queries would work. Linq is linq, the queries look the same as with linq to sql as with llblgen pro, with a tiny area where some features differ. Adding Where clauses is as simple as adding .Where calls to a query, which simply make the expression tree bigger. perhaps I'm missing something to see where you're struggling...
Otis wrote:
Don't fall into the trap that it might be possible to do so with Linq, using a fancy predicate builder. That one runs in-memory. if you want to have a db filter with linq, you have to have the field / property you're filtering on in the expression tree, OR you've to go through the unpleasant route of building Expression based subtrees with memberinfo's using reflection. This is doable, but way more code than our native api constructs.
Yes I read your response in http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=1395 : are you sure predicatebuilder does not do a db filter? when a ran http://www.codeproject.com/KB/linq/LINQDynamicPredicate.aspx and viewed the SQL in the debugger it had the filters I has selected as where clause’s. Though as one of the messages on the article said as he was just ANDing he could have used query = query.where
It does Invoke calls, which are out of the question in an expression tree. Linq to sql might handle these internally perhaps because they likely need them for their system where queries are postponed till a property is read, but in anormal query, Invoke isn't possible, it means that the expression has to be compiled and called, and you want to convert it to a predicate for a db query, so tehre's nothing to invoke: it's converted.
Otis wrote:
btw Project is up: http://www.codeplex.com/RapidDevBookCode
Thanks! I'll see if I can have a go at it and help you out porting the stuff.
I was hoping you'd say that. That would be awesome if you could
![]()
– I can add you to the project as a Developer if you would like.
Let me first check how much time I have for this project. It won't be a lot. I'll get back to you on that.