i try refactor query ef query:
select ps_adressen.adname, ps_adressen.advorname, ps_adressen.adstrasse, ps_adressen.adstrassenr, ps_adressen.adplz6 ps_besuch join ps_adressen on ps_besuch.beadnr = ps_adressen.adnr beabmonat = @month , behostessnr = @nr , (ps_besuch.bekoffer = 1 or ps_besuch.bekoffer = 2 or ps_besuch.bekoffer = 3) group ps_adressen.adname, ps_adressen.advorname, ps_adressen.adstrasse, ps_adressen.adstrassenr, ps_adressen.adplz6 having count(benr) > 1
i found post: find duplicate records in sql table entity framework
but enables me check if single value name duplicate, not different columns.
i started with:
var query = visit in db.visits join address in db.addresses on visit.addressid equals address.id group address new { address.name, address.prename, address.street, address.streetnr, address.zip, address.ziplong, visit.visitnr } temp select new { name = temp.key.name, prename = temp.key.prename, street = temp.key.street, streetnr = temp.key.streetnr, zip = temp.key.zip, ziplong = temp.key.ziplong, visitnr = temp.key.visitnr }; var list = query.where(x => x.visitnr.count() > 1).tolist();
but here clause not correct. count seems wrong..
can tell me i'm doing wrong?
thanks npadrutt
try code:
var query = visit in db.visits join address in db.addresses on visit.addressid equals address.id group address new { address.name, address.prename, address.street, address.streetnr, address.zip, address.ziplong } temp select new { name = temp.key.name, prename = temp.key.prename, street = temp.key.street, streetnr = temp.key.streetnr, zip = temp.key.zip, ziplong = temp.key.ziplong, reccount = temp.count() }; var list = query.where(x => x.reccount > 1).tolist();
Comments
Post a Comment