Asp.net uses SQL database to generate and display json strings

Source: Internet
Author: User

  DictBase(Id  (,)  ,Name ())
         

Factory method mode

IDAL layer (add an interface and define a method in it)

Obtain List <Model. DictBase>Interface: Category dictionary name

DALFactory layer (DataAccess new interface implementation factory mode)

AssemblyPath = ConfigurationManager. configurettings [ClassNamespace = AssemblyPath +Factory interface: Category dictionary name

SQLServerDAL layer (add a class in the project and inherit from the interface)

Obtain List <Model. dictBase> SQL =. format (<Model. dictBase> list = List <Model. dictBase> (SqlDataReader dr = DBUtility. dbHelperSQL. executeReader (ConnString. connReadonly, CommandType. text, SQL, = dr [(obj! = & Obj! ==( = Dr [

BLL layer (create a factory class so that it inherits from the interface, create a method, and set its return value)

Letao. IDAL. IDictBase dal = List <Model. DictBase>Specific factory type

Model layer (class)

Id {; Name {;Category: dictionary key name

Note:

DBUtility layer (DbHelperSQL class, ConnString class)

SqlDataReader ExecuteReader (connectionString, CommandType primitive type, plain text, ===Returned data content (SqlDataReader) (_ conn = System. Configuration. ConfigurationManager. ConnectionStrings [_ conn = (_ connReadonly = System. Configuration. ConfigurationManager. ConnectionStrings [_ connReadonly =Read-Only database connection string

?> <AppSettings> <add key = value =/> </appSettings>App. config file

Page

                               
   Page_Load( (Request.Headers[] !=  && Request.Headers[].ToLower() == =  (Request[] ==  = <Letao.Model.DictBase> list =  List<Letao.Model.DictBase>=

Effect

Knowledge point:

1. Convert from database to json string

2. Whether X-Requested-With is loaded for the first time

Results of Google Chrome review elements

 

Reference URL: 1. ASP. NET uses data in SQL Server to generate JSON strings

Http://www.cnblogs.com/jacksonwj/archive/2008/08/10/1264525.html

2. asp.net simple factory mode and factory method mode

Http://www.jb51.net/article/29212.htm

Related Article

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.