Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0VS 2005 TableAdapters useful in DNN?VS 2005 TableAdapters useful in DNN?
Previous
 
Next
New Post
6/23/2007 9:23 AM
 

Has anyone tried to use VS 2005's "TableAdapters" in DNN module building? I'm talking about creating the datasource/datasets visually in Visual Studio which creates the DAL for you. I've done this in a winform app and presumably can be used with website apps, but I'm not sure if this works well in a DNN module - user control.

How compatible is this with DNN's suggested DAL/BLL? I'm coming from using the Microsoft DAAB with no DAL/BLL, and the "TableAdapter" method is still new to me.

If you don't know what I'm talking about, check the tutorial out. Note that this is totally different than the DAAB/Enterprise Blocks and not even compatible with them. Also note that I've not yet worked with creating a BLL. In winforms anyway, it does not seem necessary to create these, especially when you can add this logic in the table adapters partial class (noted in the tutorial). Perhaps a BLL would be better suited in a website app.

http://msdn2.microsoft.com/en-us/library/aa581778.aspx

Jason Honingford
Website & Application Developer
www.PortVista.com


Jason Honingford - Web & Software Developer
www.PortVista.com
 
New Post
6/23/2007 10:59 AM
 

While it is possible to use the TableAdapter method specified in the article I would not recommend it.  DataSets are a very heavyweight datastructure, and typed datasets are even more heavyweight.  If you look around at much of the early documentation on ASP.Net web development, you will see that Microsoft and the development community came to a concensus that the DataReader was more performant in the web environment and thus it became the prefered data access method for web development.

Still, many people do not care for the Data Access Layer that exists in DNN because of the large number of stored procedures, DAL classes/methods and BLL classes/methods that must be maintained.  This can significantly slow development.  To simplify this maintenance step, many people have resorted to using code generators to spit out the DAL and BLL code.  There is a learning curve to make code generation techniques work, and I find that I often have a need to tweak the resulting methods so I am still stuck creating custom sprocs and the associated DAL and BLL methods..  Depending on the size and complexity of you data model, this is certainly a viable option.

The third data access method that I think more people should investigate is the use of an O/RM tool to handle the heavy lifting.  In the last 2 or 3 years a lot of great options have emerged in the .Net space:  nHibernate, LLBLGenPro, EntitySpaces, XPO, Wilson ORM, nBatis, Genome and SubSonic just to name a few of the more popular options.  Each ORM is slightly different and can provide a lot of extra value over a standard generated or hand-coded DAL.  With any decent ORM the need for stored procedures almost completely goes away.  There are a few case where stored procedures are still desired, but these are the exception rather than the rule.

Instead most ORMs dynamically generate the appropriate queries and return a domain model that is pretty close to what you are used to working with.  Most good ORMs will optimize the queries and do some caching to further improve performance.

Right now, my prefered data access tool is SubSonic.  Because it is open-source, I can use it without any licensing costs.  It implements the ActiveRecord pattern which is conceptually similar to how DNN uses controllers and info classes to expose your domain model.  The biggest draw for me with SubSonic is that it uses a BuildProvider to dynamically generate my data layer at run-time.  This means that changes to my data model are almost instantly available to my module (ok... this is stretching it a little... but it is close enough without going into specifics).  This feature allows me to easily build my application and evolve the data model as I decide to add new features or rework the data model to better handle some use cases which I may not have thought about when first sitting down to code.  I prefer a much more fluid and iterative development style that is closer to agile methodologies than the classic waterfall approach.  Having a tool like SubSonic really simplifies things for me.  Unfortunately, buildproviders do not work in medium trust environments.  To handle this scenario SubSonic allows you to generate the dal that the buildprovider would normally dynamically generate.  This means I can do development using the dynamic approach and then deploy using the generated DAL.  Personally, even if Medium Trust was not an issue, I would still prefer the generated code in a production environment since I prefer for my code to be a little more "locked down" so I know exactly what code is being executed.

Anyway, I hope that helps.

 

 
New Post
6/23/2007 1:49 PM
 

Hey thanks for the great perspective. It gives me a few things to look into, especially code generators.

I think you're right about DataSets in web apps... A DataSet would be created and destroyed with each request, where in a winform it lives in memory and can be manipulated over and over without needing to hit the database. But I'm not entirely sure that a code generated DAL/BLL is any less overhead -- that all needs to be created and destroyed too. And then you talk about optimized queries in place of stored procedures -- well maybe that speeds up development, but stored procedures are a good way to improve performance a great deal in most cases.

Yes it's pointless to use a typed DataSet if you don't use it but only to get a simple list, so I think that's why people say it is high overhead and they are right. BUT, when you combine the power of the TableAdapter, this opens up quite a lot of features to use. But again, I honestly forget whether or not the data is actually retained in memory from one request to the other it's been so long lol.

Jason Honingford
Website & Application Developer
www.PortVista.com


Jason Honingford - Web & Software Developer
www.PortVista.com
 
New Post
6/23/2007 5:36 PM
 

Actually, the code generated DAL/BLL is much less overhead if coded to use DataReaders.  A DataSet includes a lot of extra code that is useful for cursor management and other advanced features that are not used in a web environment.  Most other DALs use arrays, arraylists or simple collections to hold each of the records.  There is no overhead associated with managing dirty records, or changed fields (remember that datasets will maintain both the original and new data).

You are misunderstanding the issue of query optimization.  When you create a stored procedure, as a developer you probably create a one size fits all stored procedure for things like inserts and updates.  What if most of the time you are only changing one or two columns of data in a record?  Most hand-coded stored-procs (as least those I have seen from most developers, which includes the ones in the core DNN install) will update every column, even if only one or two column values were changed.  This means that I had to transfer all of that data to the db and required locks on the entire row rather than locks on just one or two columns.  Many ORMs are capable of seeing if a column value has changed and can craft the update query to only affect the changed columns.  This is just one example of the types of optimizations that an ORM can do. 

As a developer, you wear many hats and have to think about many different aspects of your application.  You worry about the UI, the business logic, the data layer, packaging, deployment etc.  However, ORM vendors spend the bulk of their time just thinking about how to improve the performance and capability of the data access layer.  They spend thousands and thousands of hours on something that you would likely knock out in less than a week.  To me, coding my own data layer, or using one that was whipped together for an MSDN article, would be akin to developing my own db by hacking together a thin API over a bunch of XML files.  Sure I could get it to work, and it might even perform OK, but it will never match what people have spent their entire careers perfecting.

Does that mean that an ORM is perfect in every situation?  No.  There are many cases where embedding custom logic as close to the data as possible can yield significant performance advantages.  However, keep in mind that 95% of all DALs consist of simple CRUD statments or simple table joins.

As a final point I would point you to an Article by Scott Mitchell on his thoughts about DataSets versus DataReaders for ASP.Net applications (Scott is the author of the TableAdapter article).  Personally I think Scott did  a big disservice to the community by writing the TableAdapter article.  Too often .Net and ASP.Net in particular has gotten a bad rap as trying to cater to the "new" developer at the expense of performance and maintainability.  Point and Click/Drag and Drop is great for demos but is horrible for production applications.  With less than a couple of hours of playing around with SubSonic or another ORM, you can easily get to a point where getting a SubSonic implementation up and running requires less effort that the corresponding TableAdapter based DAL.  The SubSonic/ORM based solution will not require you to sacrifice performance and will serve you better in the long run.


Joe Brinkman
DNN Corp.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0VS 2005 TableAdapters useful in DNN?VS 2005 TableAdapters useful in DNN?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out