PC Review


Reply
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average.

Which Data Acces Layer model???

 
 
ozgur develioglu
Guest
Posts: n/a
 
      25th Aug 2003
Hi everyone,

I'm trying to develop a data acces layer model for ASP.NET applications.
For every table in the database, I have a class corresponding a table. These
classes have static methods like load(...), save(...), update(...),
delete()... as classic in data acces layers.

public static SqlDataReader GetCompanies() {
SqlConnection myConnection = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);

SqlCommand myCommand = new SqlCommand("BSG_INTRANET_COMPANY_GET",
myConnection);

// Mark the Command as a SPROC

myCommand.CommandType = CommandType.StoredProcedure;


// Execute the command

myConnection.Open();

SqlDataReader result =
myCommand.ExecuteReader(CommandBehavior.CloseConnection);

// Return the datareader result

return result; }

public static DataView GetCompaniesView(){

SqlDataReader rea=CompanyDB.GetCompanies();


DataTable dt=new DataTable();

dt.Columns.Add("ID");

dt.Columns.Add("NAME");


DataRow dr;

while(rea.Read()){

dr=dt.NewRow();

dr["ID"]=rea.GetValue(0);

dr["NAME"]=rea.GetValue(1);


dt.Rows.Add(dr);

}

DataView dv=new DataView(dt);

rea.Close();

return dv;

}

So I can make bindings like:
DataView dv=CompanyDB.GetCompaniesView(); dgCompanies.DataSource=dv;
or
ddlCompany.DataSource=CompanyDB.GetCompanies();

I'm using always Stored Procedures.

Microsoft has lanced a ApplicationDataBlok called SQLHelper. This class
lets you to call SPs with less amount of code. But it is really discussable
that SQLHelper make your round trips slower. ( It's maybe faster to call a
SP directly). So I decided not to use SQLHelper classes.

I don't know using static methods make the class work slower but it
reduces the code listing as you mention.

Today I'm trying to cache some of my tables in order not to go to DB
everytime a query is made. If there is a SELECT query to Companies table, we
will look at the cache and if we find it, we will use it without going to
DB; if no, we will go to DB and put the table in the cache. if there is a
INSERT,UPDATE,SELETE query we will dispose the table in the cache.

I'm trying to make my classes work with both MS-Sql Server, ODBC, OLE
and ORACLE but I haven't find a solution for this.

I make also connection pooling with 10 minimum connections.

If you are coding such things in order to make your application working
faster, please send your comments.

Ozgur.
BSG Web Application Development



 
Reply With Quote
 
 
 
 
Kevin Swarts
Guest
Posts: n/a
 
      25th Aug 2003
[AD]
Check out nGen, http://www.nAlliance.com/Products/nGen.

It creates the classes for each table.

KS
"ozgur develioglu" <(E-Mail Removed)> wrote in message
news:Of2%(E-Mail Removed)...
> Hi everyone,
>
> I'm trying to develop a data acces layer model for ASP.NET

applications.
> For every table in the database, I have a class corresponding a table.

These
> classes have static methods like load(...), save(...), update(...),
> delete()... as classic in data acces layers.
>
> public static SqlDataReader GetCompanies() {
> SqlConnection myConnection = new
> SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
>
> SqlCommand myCommand = new SqlCommand("BSG_INTRANET_COMPANY_GET",
> myConnection);
>
> // Mark the Command as a SPROC
>
> myCommand.CommandType = CommandType.StoredProcedure;
>
>
> // Execute the command
>
> myConnection.Open();
>
> SqlDataReader result =
> myCommand.ExecuteReader(CommandBehavior.CloseConnection);
>
> // Return the datareader result
>
> return result; }
>
> public static DataView GetCompaniesView(){
>
> SqlDataReader rea=CompanyDB.GetCompanies();
>
>
> DataTable dt=new DataTable();
>
> dt.Columns.Add("ID");
>
> dt.Columns.Add("NAME");
>
>
> DataRow dr;
>
> while(rea.Read()){
>
> dr=dt.NewRow();
>
> dr["ID"]=rea.GetValue(0);
>
> dr["NAME"]=rea.GetValue(1);
>
>
> dt.Rows.Add(dr);
>
> }
>
> DataView dv=new DataView(dt);
>
> rea.Close();
>
> return dv;
>
> }
>
> So I can make bindings like:
> DataView dv=CompanyDB.GetCompaniesView(); dgCompanies.DataSource=dv;
> or
> ddlCompany.DataSource=CompanyDB.GetCompanies();
>
> I'm using always Stored Procedures.
>
> Microsoft has lanced a ApplicationDataBlok called SQLHelper. This

class
> lets you to call SPs with less amount of code. But it is really

discussable
> that SQLHelper make your round trips slower. ( It's maybe faster to call a
> SP directly). So I decided not to use SQLHelper classes.
>
> I don't know using static methods make the class work slower but it
> reduces the code listing as you mention.
>
> Today I'm trying to cache some of my tables in order not to go to DB
> everytime a query is made. If there is a SELECT query to Companies table,

we
> will look at the cache and if we find it, we will use it without going to
> DB; if no, we will go to DB and put the table in the cache. if there is a
> INSERT,UPDATE,SELETE query we will dispose the table in the cache.
>
> I'm trying to make my classes work with both MS-Sql Server, ODBC, OLE
> and ORACLE but I haven't find a solution for this.
>
> I make also connection pooling with 10 minimum connections.
>
> If you are coding such things in order to make your application

working
> faster, please send your comments.
>
> Ozgur.
> BSG Web Application Development
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
business layer, data access layer , presentation layer for asp.net using C#.net Dhananjay Microsoft VB .NET 6 20th Dec 2006 03:16 AM
business layer, data access layer , presentation layer for asp.net using C#.net Dhananjay Microsoft C# .NET 2 19th Dec 2006 10:23 AM
business layer, data access layer , presentation layer for asp.net using C#.net Dhananjay Microsoft ASP .NET 1 19th Dec 2006 12:35 AM
osi model layer vs tcp/ip model Makau Microsoft Windows 2000 Networking 10 15th Jul 2004 11:57 PM
Model of layer from Acc thru Jet database S.L. Microsoft Access Form Coding 1 11th Oct 2003 02:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:56 PM.