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