3.22 Learning to understand HttpContext and where 1=1

Source: Internet
Author: User
Tags httpcontext

1, HttpContext
HttpContext.Current.Session.RemoveAll (); Removes all keys and values from the session-state collection. (not expired, still exists)
HttpContext.Current.Session.Abandon ();? Clears all current session (expired)
2, where 1 = 1
The condition after 1=1 in the where condition is changed dynamically through the If block. For example:
String sql= "SELECT * FROM table_name where 1=1";
if (Conditon1)
{
sql=sql+ "Andvar2=value2";
}
if (Conditon2)
{
sql=sql+ "Andvar3=value3";
}
Where 1=1 is to avoid a syntax error because the first word that follows the WHERE keyword is directly "and". 1=1 conditions, typically used to construct dynamic SQL statements, "SELECT ... From ... WHERE 1=1 "+ dynamic construction condition clause.

3.22 Learning to understand HttpContext and where 1=1

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.