views:

229

answers:

3

I am in the early stages of planning a conversion of a large classic ASP database application to ASP.Net and I'm having trouble picking out which data access method to use. I have played around with Linq To SQL, Dynamic Data, strongly typed datasets, Enterprise Library (Data Access Application Blocks), and a tiny bit with Entity Framework, but none of them have jumped out to me as "the one". There are just too many choices - my head is swimming, help me choose!

Perhaps it would help to give some background on the application that I am converting along with the priorities...

  • The back end is Microsoft SQL Server (2005 or later) and we are committed to that, so I don't need to worry about ever supporting a different database platform.

  • The database is very mature and contains a great deal of the business logic. It is highly normalized and makes extensive use of stored procedures, triggers, and views. I would rather not reinvent two wheels at the same time, so I'd like to make as few changes to the database as possible. So, I need to choose a data access method that is flexible enough to let me work around any quirks in the database.

  • The application has many data entry forms and extensive searching and reporting capabilities (reports are another beast which I will tackle later).

  • The application needs to be flexible enough to deal with minor changes to the database structure. The application (and database) may be installed at different sites where minor custom modifications are made to the database. Ideally the application could identify the database extensions and react appropriately. In other words, if I need to store an O/R mapping in the application, I need to be able to swap that out (or refresh it easily) when installing the application and database at a new site.

  • Rapid application development is critical. Since the database is already done and the user interface is going to closely match the existing application, I'm hoping to find something where we can crank this out fairly quickly. I am willing to sacrifice not using the absolute latest and greatest technology if it will save time in development. In other words, if there is a steep learning curve to using something like Entity Framework, I'm fine with going something like strongly typed Datasets and a custom DAL if it will speed up the process.

  • I am a total newbie to ASP.Net but am intimately familiar with Classic ASP, T-SQL and the old ADO (e.g. disconnected recordsets). If any of the data access methods is better suited for someone coming from my background, I might lean in that direction.

Thanks for any advice that you can offer!

+1  A: 

nHibernate might be a good fit. You can store the mapping in external configuration files which would solve your needs. Another option might be using ActiveRecord, which is based upon nHibernate.

nHibernate has a neat feature which you might find helpful. It's called a Dynamic property which is basically a name value pair collection populated by pulling the column names from the mapping file. So when you add a column at your client site, you update the mapping file and you'd be able to access the data through a collection on the object.

JoshBerke
With so many ways to do the same thing, I would like to see what 1 tool is good for vs other (i.e. when to use which one)? along with evaluation of tools on some parameters (e.g. learning curve, maintenance, simplicity, community support etc.)
shahkalpesh
I've heard nHibernate is very powerful, but I have also read that the learning curve is pretty steep in order to use it the right way. Unfortunately we don't have that kind of time.
CowherPower
how much time do you have? It took me a couple days to figure out how to map my first object graph 3 at the most. I'm a developer of 1, sounds like you have a team.
JoshBerke
+5  A: 

Look at all three articles in this series:

High Performance Data Access Layer Architecture Part 1

Great advice.

Gary.Ray
Thanks, that was a very interesting series of articles. If I decide to build my own DAL from scratch, I may use this method. But I'll have to convert it to VB since I don't really know C# very well.
CowherPower
Most of it will convert easily - especially if you use a tool like Reflector to disassemble the binaries to VB.Net.Also, remember, in your solution even if your presentation layer is vb.net your DAL, DTO's and business layer can be C# if you wanted to go that direction.
Gary.Ray
I also found this cool site which will convert C# to VB.net for you. It seems to work pretty well: http://www.developerfusion.com/tools/convert/csharp-to-vb/
CowherPower
+2  A: 

You may want to look at decoupling the database layer from the asp layer so that you can not only give more flexbility in making the decision, but when you have to make changes to a customer's database you can just swap in a new dll without changing anything else.

By using dependency injection you can use xml to tell the framework which concrete class to use for an interface.

The advantage to doing this is that you can then go with one database approach, and if you later decide to change to another, then you can just change the dll and go on without making any changes to other layers.

Since you are more familiar with it why not just go directly to the database at the moment by making your own connections? Then you can move the rest of your code and along the way you can decide which of the myriad of technologies to use.

For a new application I am working on I am starting with LINQ to SQL for it, mainly because development will be quicker, but, later, if I decide that won't meet my needs I will just swap it out.

James Black
When you say "why not just go directly to the database" are you talking about using things like SQLDataSource and datasets directly? I'm not opposed to that, but I don't want to go that route if the newer technologies have not made the "direct" method obsolete (or a foolish choice).
CowherPower
You may find this url interesting for performance:http://toomanylayers.blogspot.com/2009/01/entity-framework-and-linq-to-sql.htmlA DataReader would be a usefulchoice, perhaps.I don't think the direct route is obsolete, and if it speeds up your development, for maintaining, later, you may want to change.
James Black
Interesting article. I was already leaning against using Entity Framework and this pretty much seals that decision.
CowherPower