Thoughts on Data Reading Efficiency

Source: Internet
Author: User

Recently, I encountered some questions when I was working on some web projects. when I started development, I thought as long as the function was done. but after a long time, I want to do some well-structured and quality projects on my own. however, I still have some questions. let's talk about it here.
The first is about the layer-3 architecture. I read a lot of things online. but most of them are the same. it is generally called an object class. data Layer and business layer. I still understand this idea. however, the differences between the data layer and the business layer are not clear. I personally feel that the operations at the data layer are the same as those at the business layer. for example, a user table. I may create an object class in the model. then, perform some operations on the object class in the data layer. for example, add a user and obtain details of the user according to the user ID. however, at the business layer, I still write these methods and then call the methods in the data layer. basically, there is no change. sometimes I think this business layer is necessary.
Business Layer =? Data layer, hope you can give me some advice.
The second is a small problem:
I would like to ask, for example, if I have two repeater on one page to bind data, do I use a stored procedure to return both tables or try to bind one table in two separate workshops. in this way, the efficiency is better.
For example, when a user information is obtained at the data layer
 

Code
  Public Thistoryuser getuserbyid ( Int ID)
{
Sqlparameter [] Par = Sqlhelperparametercache. getspparameterset (connstr, " P_admin_gethistoryuser " );
Par [ 0 ]. Value = ID;
Par [ 1 ]. Value =   0 ;
Par [ 2 ]. Value =   1 ;

Thistoryuser user=   New Thistoryuser ();
Using (Sqldatareader SDR = Sqlhelper. executereader (connstr, " P_admin_gethistoryuser " , Par ))
{
If (SDR. Read ())
{
User =   New Thistoryuser ();
User. ID =   Int . Parse (SDR [ 0 ]. Tostring ());
User. Username = SDR [ 1 ]. Tostring ();
User. userid = SDR [ 2 ]. Tostring ();
User. HTTP = SDR [ 3 ]. Tostring ();
User. weburl = SDR [ 4 ]. Tostring ();
User. IP = SDR [ 5 ]. Tostring ();
User. platformid =   Int . Parse (SDR [ 6 ]. Tostring ());
User. adddate = Datetime. parse (SDR [ 7 ]. Tostring ());
}
}
Return User;
}

This sectionCodeWhat are their advantages and disadvantages?
I hope you can give me some suggestions. Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.