Three ways to remove duplicates from EF+LAMDBA

Source: Internet
Author: User
Tags date1

Today, when writing the project, this problem occurred, after Baidu and help people to help the end of the original LAMDBA is to remove the duplicates of var Total1 = db. Nikedtcdailyreport.where (p = p.cn_launch_date >= date1 && p.cn_launch_date <= date2). Where (p = p.cn_planning_qty! = 0). ToList (); var total2= total1.where ((x, i) = Total1.findindex (p = = P.style = x.style) = = i). Count (); the second type isvar SDLDelivered1 = db. Nikedtcdailyreport.where (p = p.cn_launch_date >= date1 && p.cn_launch_date <= date2
&& P.cn_planning_qty! = 0 && P.lw_specs_review = = NULL && P.sample_batch = = NULL && P.revi Ew_request_to_category = = NULL && P.review_back_from_category = = NULL
). Where (p = = P.cn_cn_copy_status__y_n_ = = "Y"). Select (P=>p.style). ToList ();
var SDLDelivered2 = sdldelivered1.distinct (). Count (); Most people are aware of the turn-to-set trial distinct to remove the repetition of the third clock var CategoryReviewwing1 = db. Nikedtcdailyreport.where (p = p.cn_launch_date >= date1 && p.cn_launch_date <= date2)
. Where (p = p.cn_planning_qty! = 0 && P.review_request_to_category! = null &&
P.review_back_from_category = = NULL
). AsEnumerable (). ToList ();
var CategoryReviewwing2 = categoryreviewwing1.groupby (o = = new {O.style}). ToList (). Exists (g = G.count () > 1);

var CategoryReviewwing2 = categoryreviewwing1.groupby (o = = new {O.style}). Where (g = G.count () >= 1). ToList ();
var CategoryReviewwing2 = categoryreviewwing1.groupby (o = = new {O.style}). Where (g = G.count () >= 1). Count ();

It notes how much of the duplicate data the query has, and the second one is to the list collection, and the third is converted to the int type.

Three ways to remove duplicates from EF+LAMDBA

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.