c# - Entityframework.extensions error "Sequence contains more than one element" on batch delete -
i using entityframework.extended library in project, contains code first entity model. receiving error message "sequence contains more 1 element" when execute linq statement , perform batch delete library:
var subjlocal = (from subjectlocal in customercontext.rostersummarydata_subject_local ((subjectlocal.fkrostersetid == 0) && (statsinfo.testinstanceidslist.contains(subjectlocal.fktestinstanceid)) && (subjectlocal.fktesttypeid == statsinfo.testtypeid) && (statsinfo.schoolyearidslist.contains(subjectlocal.fkschoolyearid)) && (subjectlocal.fkrostertypeid == 1) && (subjectlocal.fkschoolid == 0) && (subjectlocal.fkdepartmentid == 1) && (subjectlocal.fkcourseid == 1) && (subjectlocal.fkperiodid == 1) && (statsinfo.democatidslist.contains(subjectlocal.fkdemocommoncategoryid)) && (statsinfo.democodeidslist.contains(subjectlocal.fkdemocommoncodeid)) && (statsinfo.testsubjectidslist.contains(subjectlocal.fktest_subjectid))) select subjectlocal.pksummarysubjectlocalid).toarray(); if (subjlocal.length > 0) { customercontext.rostersummarydata_subject_local.where(s => subjlocal.contains(s.pksummarysubjectlocalid)).delete(); customercontext.rostersummarydata_subject_local_bands.where(s => subjlocal.contains(s.fksummarysubjectlocalid)).delete(); customercontext.rostersummarydata_subject_local_averages.where(s => subjlocal.contains(s.fksummarysubjectlocalid)).delete(); customercontext.savechanges(); }
the error occurs at:
customercontext.rostersummarydata_subject_local.where(s => subjlocal.contains(s.pksummarysubjectlocalid)).delete();
customercontext base entity inheriting dbcontext , rostersummarydata_subject_local / _bands / _averages child tables. importing library using reference , notices delete() method works properly:
using entityframework.extensions;
isn't purpose of batch delete make sure can delete multiple items @ once , shouldn't sequence contain more 1 element? there missing here?
you can find similar post entityframework.extensions 6.1 batch delete throws "sequence contains more 1 element" here.
according @deherech seems bug in extension framework
Comments
Post a Comment