views:

64

answers:

0

Suppose one has a number of databases -- 20 or more. Many seperate "workflows" of homogenous ASP.NET WebForms are used to provide a way for users to either insert or retrieve records from the databases. The forms are linked by a central user base and permissions model (which is not necessarily a factor in this question.) Very little "business logic" exists. Rather, entry fields must simply be validated and then the data is inserted. Essentially, it's just a suite of "forms and reports."

Due to the sheer number of databases, and tables -- a large number of strongly typed data access classes that represent all of the tables and columns would be unwieldy. Following that pretense, ORM packages like Entity Framework / NHibernate / etc. are not welcomed in this scenario.

What data access class structures would work in this scenario to reduce repeated code?

At present, static data access classes for each "form" simply wrap low-level ADO.NET components around the only two things that are unique between the forms: the connection string and the particular stored procedure that retrieves or creates the data. Parameterrs come into the method via function parameters which are then simply added to a SqlCommand parameter collection. This requires repitition of boiler plate code throughtout the library of forms. It also requires one to modify every data access method signature to contain parameters that match the stored procedure columns, modify the GridView databound column list to match the output parameters, modify the paramater .Adds for the SqlCommand to match the sproc parameters (on an insert, this could be 20 or more), etc. Plenty of needless repetition.

What sort of class hierarchy could be used to prevent this? Should the data access classes inherit from a base class? Should generics be involved? Are DataSets the optimal way to pass data from the data access layers to the GridViews?

Since very simple things are occurring, what could be done to make the code simple? At present, the data access classes are minimally sized while code-behinds are 500 to 3000 lines.