 |
|
 |
Overall this is a nice start and it is very promising.
Together mit fluentMigrator[^] and Using DynamicObject to implement general proxy classes[^] definitely something to look at.
But while playing around with the tests ( unfortunately you didn't provide the create SQL ) i realised that
you parse everything down to a string.
All the ParseNode funktions should return an object instead of a string and then
together with a ParameterFactory this should get it right.
Otherwise keep up the good work.
You got my 5.
|
|
|
|
 |
|
 |
What you have done here, in my opinion, is exceptional. I too am of the camp that I should not have to take care of an exponential number of objects just to access data within the database.
Done correctly something like this significantly reduces code bloat while still allowing for delegation of responsibilities at the various layers.
HOWEVER! To not correct an omission of a dependent class since June 10th is, to say the least, frustrating. I honestly believe in what you are trying to promote, and stress again that something this powerful needs to be used responsibly, but it's negligence like this that reflects poorly for your cause.
For whatever reason the article: "Getting your metadata when you need it from the database" is no longer available, priceless!
So now I'm off to reverse engineer your SqlHelper object so that I can fully digest what you've done here.
|
|
|
|
 |
|
 |
stay tunned, an updated version is being prepared, will be ready in a couple of weeks!
|
|
|
|
 |
|
 |
That's great news. I didn't mean to sound too harsh, and upon re-reading what I wrote it did indeed sound harsh. But it can be frustrating when you trying to quickly follow an idea to it's resolution only to by stymied by ideas that dead-end.
I'll keep checking back as I'd like to compare my derived implementation with yours.
|
|
|
|
 |
|
 |
Well, yes, a bit harsh it was, but you had a point. Take a look at this new updated version 2.0. Everything is included, the code itself, the helper libraries, and the examples.
|
|
|
|
 |
|
 |
Firstly, this appears to be quite useful, as I don't like mapped solutions either(I never warmed up to NHibernate).
However, I have a few questions/problems.
1. The download is missing a dependency - SQLHelper
2. The download contains no samples
3. The first example shown leaves the mystery of where did the variable TEmployees come from(it would have been solved if the samples had been included).
4. I noticed that the article didn't say part 1, but the download does. Which is correct?
Good work(deepobject as well).
|
|
|
|
 |
|
 |
You are right and I apologize.
I'm going to prepare an updated package, if I have time enough also including the suggestions other people have proposed. Very busy right now, probably I'll need some time before i can have it.
Thanks. M
|
|
|
|
 |
|
 |
No problem, I know how it is.
You have made some really nice contributions to the community, and you don't owe anyone an apology.
Keep up the good work.
|
|
|
|
 |
|
 |
In the updated version 2.0 I remembered your notes, and all the examples are included (along with the helper libraries as well).
|
|
|
|
 |
|
 |
Does it support different DBMSs, like MS-SQL, PostgreSQL, MySQL, DB2, Firebird, etc...?
|
|
|
|
 |
|
 |
Short answer: not in its current stage.
But I don't see any major conceptual barrier to introduce this capability. I need a replacement for the MetaBase, MetaTable and MetaColumn classes that can cope with all those idioms you mentioned. And then, modify the parser and the translator (which wouldn't be a bid deal if you are fluent in those parlances, which I am not).
Actually some refactoring would be also needed in the MetaQuery class and related: the SQL translator is splited among a few methods, being the more important ones the _Visit() and related, the _...GetCommand(), and the _...Parse() ones. Also some modifications would be needed when producing the actual command string, in the ToString() method, and maybe in the internal _ReadNextRecord() method.
I have not the infrastructure not the knowledge to make it generic enough to support all the specifics of those SQL parlances. But I'm open to receive suggestions and modifications.
Thanks. Regards, M
|
|
|
|
 |
|
 |
Version 2.0 is now refactored in order to allow the inclusion of other SQL varieties.
It should be a matter of override the virtual functions of the abstract classes provided, to implement the interfaces, and to pay attention to its overloaded ToString() methods, where the actual SQL commands are built.
Though, I have included only the MS-SQL one, is the only test bed I have handy.
|
|
|
|
 |
|
 |
If you are using WebServices or WCF would you envisage this being used within a WCF service or will the UI (client) directly use a metaquery.
If it intended to be used inside a WCF service, why would I not use LINQ to SQL or LINQ to EntityFramework which do this same job right?
If the idea is that the UI (client) uses you metaquery, would you just send the resulting SQL query string to the WCF service and allow it to send back the results.
I am assuming as you are using dynamic and Expressions, you never intended to be able to run a query on the client which would go through WCF or something like that, and then inside the WCF layer the database is called. I guess this would not work for you as you can not serialise dynamic and expression trees.
Do you see what I mean
So this means you either use this on your service side, in which case why not use LINQ to SQL or LINQ to EntityFramework which do this same job.
Or if you are using this on the UI (client) directly that implies I have a direct link to the database on my clients right?
Is that about right? If it is I would more than likely not go this way, as I prefer thin clients, and SOA approach.
I guess this is more like UI -> Database right?
Anyway good job, but if you could just answer those few questions I would be very happy.
The reason I ask is that we wrote a query language that is serializable but it obviously relies on strings, as we can not serialize delegates or expression trees over WCF boundary.
Sacha Barber
- Microsoft Visual C# MVP 2008-2010
- Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
My Blog : sachabarber.net
|
|
|
|
 |
|
 |
Hi. Good questions indeed.
I haven't (yet) tested MetaQuery in a WCF scenario, so far it does its job in heavy-client and web-based ones though. For WCF, for starters I assume that serialization capabilities are needed.
Firstly, to return the results back. To that end, DeepObject is basically a list of lists, to I don't see any major problem to incorporate serialization to it (as far as the "values" each member contain are serializabled by their own). I'll take a look at that soon.
Secondly, what MetaQuery basically does is building a string command using the right SQL syntax, obtaining the specifications from delegates that accept dynamic arguments. It does not use Linq Expressions (that neither are serializable nor they accept dynamic arguments), but "decompiles" (so to speak) and translates into SQL parlance the delegates' code used to build the query. Even in a light-client scenario I bet you can use this capability in the client side, and then send the command string you've built across the wire. Yep, you may have to refactor a bit the classes, but it is achievable.
Anyhow, both L2S and L2EF use external mapping files for serious environments (I mean, not the quick & dirty testing scenarios). It might be personal, but I dislike them, I feel it is not very well solved the fact that I have to go through a re-creation of all the stuff when a single bit in the database changes (although partial classes are a help), and even more important I dislike having to alter my business object classes with database related stuff.
Finally, any of those Linq2xxx allow me to write queries using dynamics. But by using them I have a very flexible way to express SQL syntax from C# code, and I can refer to private members of the business classes if needed - and with tyhe help of reflection even if I have no access to their source code. Yes, you can write the command strings straight instead of using a dynamics-based delegate, but you'll miss the second part (and it is nice to have both capabilities at once in the same place).
I'll see if I can find some time to test WCF and similar scenarios, very good point. I'd love to hear is you test them as well.
|
|
|
|
 |
|
 |
Good answers there, thanks for them. I am really busy right now, but I would like to give this a try with WCF at some stage (though that may never happen, as I am so so busy right now).
But I would love to see you update this post trying this out, if you could do that, I think you would be truly on to something, where I can create a query on the client and it gets sent to WCF and the WCF service calls DB and returns results.
I think that would be amazing, and I would love to hear back from you if you try that out.
Sacha Barber
- Microsoft Visual C# MVP 2008-2010
- Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
My Blog : sachabarber.net
|
|
|
|
 |
|
|
 |
|
 |
Yep, I knew it already.
It uses the route of actually decompiling the IL code and generate an actual Linq.Expression tree out of it. But's like killing ants with an A-bomb for the needs of MetaQuery - and anyhow, I'm not comfortable with IL, and it was done for Mono.
Regards, M
|
|
|
|
 |
|
 |
Fair enough, Like I say please let me know if you test this with WCF, I would love to see it. This does look very promising
Sacha Barber
- Microsoft Visual C# MVP 2008-2010
- Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
My Blog : sachabarber.net
|
|
|
|
 |
|
 |
Version 2.0 is now refactored so that it is only based internally in strings: there should be no problems to use in remotable or WCF scenarios (at least the part that build the SQL commands).
Also, it does now allow several SQL varieties, and permits external DbConnection objects to allow several commands to be issued whithin a single transaction.
|
|
|
|
 |
|
 |
Shall have to take it for a try
Sacha Barber
- Microsoft Visual C# MVP 2008-2010
- Codeproject MVP 2008-2010
Your best friend is you.
I'm my best friend too. We share the same views, and hardly ever argue
My Blog : sachabarber.net
|
|
|
|
 |