Checking for duplicate rows using Entity Framework in C# -
using entity framework 6.x. entities after create new instance of entity object , populate data values, able trigger lookup on database. see if row exists same values populated entity object , if exists return primary key.
it seems logical there should standard way built entity framework can't find it. nice if there method take entity object , return primary keys of matching rows.
what's wrong doing firstordefault()
filter retrieve entity matching values?
var entity = new entity { // initialize properties } var matched = dbcontext.entitytable.firstordefault(x => x.propa = entity.propa && x.propb = entity.propb);
(don't have ef on machine right now, actual access code psuedo)
Comments
Post a Comment