|
Marc, let me throw this into the fire. EntitySpaces, a new architecture I've created with others through EntitySpaces LLC generates SQL on the fly, and it gives it back to you so you can see it if you so desire. You can also write an EntitySpaces project for Oracle and run the EXACT same code on Access, Oracle or MySQL without recompiling, it's merely a connection string change. However, it is all strongly typed, but very lightweight, and generateable. We use inheritance to avoid regeneration errors, your custom classes inherit from the generated classes, you never hand edit the base (generated) classes, you just override any methods or properties in your custom class. Thus, when you look at your custom code classes they are either empty (because the generated class does it all) or they only contain your real business logic which makes it very nice indeed.
The nice thing about this approach is there are never runtime errors. The code compiles 100% clean and we never use hard code fields names, "EmployeeID" rather we use Employees.Columns.EmployeeID. You can write a query like this, via intellisense, and it runs on any database:
public partial class EmployeesQuery: esEmployeesQuery
{
public bool CustomLoad()
{
Select(EmployeeID, FirstName, LastName, TitleOfCourtesy)
.Where
(
Or(LastName.Like("%A%"), LastName.Like("%O%")),
this.BirthDate.Between("1/1/1940", "1/1/2006")
)
.OrderBy(LastName.Descending, FirstName.Ascending);
return this.Load();
}
}
It's amazing how productive we are with this approach, so easy a child could do it, and it's generated in seconds, and can be regenerated in seconds if/when the schema changes.
Employees entity = new Employees();
entity.AddNew();
entity.FirstName = this.txtFirstName.Text;
entity.LastName = this.txtLastName.Text;
entity.Save();
Look at that code above, spoon fed via intellisense, it functions with or without stored procs, you get to choose, and runs on any provider, strongly typed, serializable and so forth ...
Mike Griffin
EntitySpaces LLC
http://www.entityspaces.net
-- modified at 10:31 Wednesday 26th April, 2006
|
|
|
|
|
You can also write an EntitySpaces project for Oracle and run the EXACT same code on Access, Oracle or MySQL without recompiling, it's merely a connection string change.
Mike, I hope you meant that if you wrote a project for Oracle, you have to keep your db exactly the same on mysql, access, sqlserver etc.
It's hardly ever just changing the connection string. If I have a project on SqlServer, with GUID's, bitfields and the like, no way I'll be able to use that same project on Oracle without converting data somewhere: Oracle doesn't have a GUID type nor a bittype.
We use type converters behind the scenes so you can keep your entity code like:
myCar.IsCabrio = true;
and be able to save that myCar in Oracle, or whatever DB, though it'll never be just a switch of a connection string for the developer. At runtime, sure, just switch between adapter instances, per call, and you can access whatever db you like, but during development, it's not possible.
Or the DB has to obey strict rules like only use types from this small list etc. and that's too restrictive.
--
Lead developer LLBLGen Pro: http://www.llblgen.com
Only the true wise understand the difference between knowledge and wisdom.
|
|
|
|
|
Actually, we have a huge NUnit Test suite that runs against EntitySpaces available for download to all registered users. We run a huge battery against Oracle, Access, Microsoft SQL, and MySQL using the same exact binary code, the only difference being the EntitySpaces connection string entry in the config file, which also indicates whether you want to use stored procedures or dynamic sql, and whether you want ADO.NET command based transactions or enterprise distributed transactions, all in all it's like 30 some odd configurations all driven by the config file.
You are correct that you have to use a subset of all available datatypes of course, however, it's very forgiving, we use a 'bit' for boolean in SQL and in Oracle it's represented by a 'number' and it all works fine. EntitySpaces does an excellent job with provider independence actually.
See http://www.entityspaces.net/portal/Documentation/TestSuiteGettingStarted/tabid/99/Default.aspx[^]
Maybe you can study our techniques and improve LLBLGen if you're having trouble with provider independence?
|
|
|
|
|
Though are these conversions hardcoded? I mean, if I have an entity class with a boolean field Foo, and I want to save it into oracle, I have to have a field NUMBER(1,0) there? What if I want to map it onto CHAR(1) with Y and N ?
I also just switch a connection string to test a set of tests against oracle or sqlserver or other database, though don't have to limit myself to a subset of types nor does the db schema have to obey restrictions, while your schemas IMHO have to obey restrictions as in: it won't work with every legacy db / existing db out there.
--
Only the true wise understand the difference between knowledge and wisdom.
|
|
|
|
|
No, the mappings are dynamic, we use a rather interesting feature of ADO.NET to accompish it, it's a very powerful approach actually, it will darn near map anything to anything ...
|
|
|
|
|
I must be missing a part of the ADO.NET manual then, because I don't recall a feature which can map any type onto any other type for data persistence/retrieval.
Also, if it's true what you're saying, why do you still need a subset of the types?
--
Lead developer of LLBLGen Pro: http://www.llblgen.com
Only the true wise understand the difference between knowledge and wisdom.
|
|
|
|
|
I said "darn near" that's why
|
|
|
|
|
But you're not going to explain which feature you alone have found in ado.net to do this?
--
Lead developer of LLBLGen Pro: http://www.llblgen.com
Only the true wise understand the difference between knowledge and wisdom.
|
|
|
|
|
No, being a weekend warrior and not a full timer like yourself I need an edge ...
|
|
|
|
|
Haha Ok, I give you that :P
To help you get some sleep over the weekend: I use TypeConverter derived classes to convert back/forth between types. These classes are assigned to an entity field, so you can thus effectively map any .NET type you want onto any .NET type. The core sees the type converters and uses them to convert values back/forth when values are read or when values are written. This is completely transparent so I can map a string to an XmlDocument and back or a blob to a real Image object and back etc. and thus choose with the proper converter on which native db type I'll map it.
--
Lead developer of LLBLGen Pro: http://www.llblgen.com
Only the true wise understand the difference between knowledge and wisdom.
|
|
|
|
|
Btw, I see you got over 50 votes in the last half hour... impressive!
--
Lead developer of LLBLGen Pro: http://www.llblgen.com
Only the true wise understand the difference between knowledge and wisdom.
|
|
|
|
|
We alerted our user base to poll, given that we get a 1,000 downloads a week it I expect it to continue climbing for a while. So many times MyGeneration is nominated for things and we never know about it until the contest is over ... I thought it would be good for once to have a show of force so folks realize MyGeneration is "for real"
|
|
|
|
|
What you're describing sounds almost like Ruby's ActiveRecord. Have you looked at that at all? (Oh...and is all this in the MyXaml package?)
Oh geez... the forum keeps spinning... you'll take care o f it i'm sure, c'ause ... yeah, i neede this. *cough* anyway good job finding the bug. -Shog9 on...a Firefox bug.
|
|
|
|
|
David Stone wrote: Have you looked at that at all?
Yes, in fact, there seems to be a lot of similarities on the surface, but I haven't dug down to look at the details. But the Ruby stuff seems VERY similar.
David Stone wrote: and is all this in the MyXaml package?)
Nooooo. I'm hoping to make this a commercial product. A loooong journey, there.
Marc
Pensieve
Some people believe what the bible says. Literally. At least [with Wikipedia] you have the chance to correct the wiki -- Jörgen Sigvardsson
|
|
|
|
|
Microsoft .Net solutions really don't compare with scripting language solutions - even OOP ones like Ruby. Things must be attacked differently when you don't have a compiler or the powerful intellisense that Visual Studio provides. If I was doing a Ruby project, I wouldn't want strongly typed objects/members at all. I would want a lean, mean, runtime machine.
|
|
|
|
|
I'm fully aware of that. I use LLBLGen for my OR/M layer. I was just remarking on the fact that Marc's framework sounds an awful lot like ActiveRecord.
Oh geez... the forum keeps spinning... you'll take care o f it i'm sure, c'ause ... yeah, i neede this. *cough* anyway good job finding the bug. -Shog9 on...a Firefox bug.
|
|
|
|
|
I use MyGeneration to generate dOOdads objects.
Because you can also write your own templates, MyGeneration can be used to create your own data-tier. Infact you can use it for existing ones like Gentle.NET, NHibernate, Opf3 and more.
It's free too. So I am surprised more don't use it. A new version (based on .NET 2.0) will be coming out (within the year hopefully) which will be even better (that will be an achievement in itself).
|
|
|
|
|
I spent a few days writing a MyGeneration template to create the shim classes required for dOOdad objects to mesh well with the ASP.NET 2.0 GridView. As it turns out, EntitySpaces does everything I was trying to accomplish RIGHT NOW.
Now, I'm rewriting my app code to switch over to EntitySpaces.
|
|
|
|
|
I use also MyGeneration to generate dOOdads objects.
I like this because it's handy and also you'll get quick an answer for a question in the forum.
May there will be an option for me change to EntitySpaces in the futures. But at the moment
this tool fits for me.
Great, thank the develeoper for this great Tool. Good works.
|
|
|
|
|
EasyObjects.NET - The O/RM for Microsoft's Enterprise Library
- An Object/Relational Mapper (ORM) library written entirely in C# and built on top of Microsoft's Enterprise Library and the Data Access Application Block (DAAB).
- Map data in your tables to strongly-typed objects with built-in features for looping, data binding and null-value handling.
- Advanced database features include bulk saving, transaction support, a custom dynamic query syntax and dynamic connection strings.
- Support for SQL Server and Oracle included.
- Support for custom dynamic query providers, controlled by configuration file.
- Code-generation scripts for the popular MyGeneration code generator.
- Feature compatible with Mike Griffin's dOOdads architecture.
- New in 1.1! Ability to perform all database operations without stored procedures.
- New in 1.1! Support for SQL aggregate functions.
There is also a .NET 2.0 version available as a Community Technology Preview.
Matt Noonan
http://www.easyobjects.net
|
|
|
|
|
EntitySpaces is a new Architecture for .NET 2.0 and can be found at http://www.entityspaces.net EntitySpaces is truly provider indendent and generated by MyGeneration. We have Sql, Access and Oracle support now, our next release will have MySQL support. EntitySpaces can run with or without stored procedures and has a powerful dynamic query syntax, supports serialization and makes a great alternative to the DotNetNuke DAL for DotNetNuke Development
Mike Griffin
EntitySpaces LLC
http://www.entityspaces.net
|
|
|
|
|
Hello,
I use no tool for my data layers at the moment. The project that I currently work on (my graduation project) is not long enough to get to that phase. The other developers I work with don't use a tool either.
After I graduate - and when I'be employed by my current employer - I'll start to look for a tool that supports my demands:
<list>Generates database and related classes based on a description (possible XML hidden by a GUI). This will be for simple applications
Generates a data layer with mapper classes that map the domain objects to the database. This should be possible based on metadata and hopefully for .NET assemblies in some way (serialization?). This will be for the more complex systems with extensive domain models
Should support transaction management to some degree and things like a Registry, etc.
Does anybody know an application that supports these demands?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote: Should support transaction management to some degree and things like a Registry, etc.
Registry??
Norman Fung
|
|
|
|
|
A registry makes sure that a domain object is loaded only once from the database. For example when thread A request a domain object with ID 1, the registry loads it from the database. Now a second thread also requests a domain object with ID 1, the registry returns the already loaded domain object instead of loading another copy from the database. Offcoarse you have to have some transaction management and the like.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
|