The application of the anti-DDoS principle and SQL in keywords in EF, sqlef

Source: Internet
Author: User

The application of the anti-DDoS principle and SQL in keywords in EF, sqlef

Suddenly realized the importance of words, so I began to write my first blog, with the goal of keeping a close record for ease of understanding.

At the same time, I also hope that the brick-and-mortar market can play a role in promoting mutual learning. You are welcome to express your thoughts and thoughts!

Background:

During the electronic fencing of Baidu map, the FenceUser field (Data Format:, 7) in the FenceUser field (Fence) in the FenceUser field of a Fence is directly updated, at the same time, update whether the FenceFlag (0 or 1) of the corresponding ID (1, 3, 7) of the User table is set to FenceFlag (0 or 1)

Therefore, we need to compare the Non-Public part of the corresponding ID value passed from the front-end and the corresponding ID value in the database, and then uniformly reverse the FenceFlag mark of the User table.

 1 DBConn db = new DBConn(); 2             var fencelist = (from b in db.Fence.AsNoTracking() where b.fenceId == fenceID select b).ToList(); 3             string fenceusers = fencelist[0].fenceUsers; 4             string[] users = fenceusers.Split(','); 5             string[] arraymembers = ArraymembersToid.Split(','); 6             var listTemp = users.Concat(arraymembers).Except(users.Intersect(arraymembers)).ToList(); 7             var list = listTemp.Select<string, int>(q => Convert.ToInt32(q)); 8             var userFenceFlag = db.Users.Where(p => list.Any(a => a.Equals(p.id))).ToList(); 9             if (userFenceFlag.Count > 0)10             {11                 foreach (Users user in userFenceFlag)12                 {13                     user.FenceFlag = -(user.FenceFlag - 1);14                 }15                 db.SaveChanges();16 17             }
View Code

Keywords:

Set

Intersect: intersection

Distinct T: difference set (A difference B refers to the differences between A and B, rather than all AB values)

Concat: Collection (all AB values, including duplicates)

EF

Any: similar to IN

 

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.