3. Example

Source: Internet
Author: User

Summary:

A simple message board can be implemented simply by writing a little bit of code. Shows the convenience and powerful functions of LINQ.

 

Content:

Process:

1. Create a database

2. Create a webapp and attach a database

3. Add the LINQ to SQL classes to automatically complete many tasks.

4. Page Layout

5. Background code

A) *** datacontextctx = new *** datacontext ("connection ");

B) read the data and send it to datasource

Rpt_message.datasource = fromgb in CTX. tbguestbooks orderbygb. posttime

Descending select GB;

Rpt_message.databind ();

C) data modification

Tbguestbook GB = CTX. tbguestbooks. Single (B => B. ID =

New GUID (E. commandargument. tostring ()));

CTX. tbguestbooks. Remove (GB); // expired

CTX. submitchanges ();

D) log records

Streamwriter Sw = newstreamwriter (server. mappath ("log.txt"), true );

CTX. log = Sw;

Sw. Close ();

6. Other knowledge

GB. ID = guid. newguid (); // automatic primary key value ????

 

Download source code here

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.