本文整理汇总了C#中CmsEntities.DeleteWhere方法的典型用法代码示例。如果您正苦于以下问题:C# CmsEntities.DeleteWhere方法的具体用法?C# CmsEntities.DeleteWhere怎么用?C# CmsEntities.DeleteWhere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmsEntities
的用法示例。
在下文中一共展示了CmsEntities.DeleteWhere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveIssueRelatedIssues
private void SaveIssueRelatedIssues(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueRelatedIssues()");
//Delete
cee.DeleteWhere<IssueRelatedIssue>(cee, x => x.IssueId == issue.Id);
cee.Configuration.AutoDetectChangesEnabled = false;
var existingRelatedIssues = cee.IssueRelatedIssues.ToList();
//Save IssueRelatedIssues
foreach (IssueRelatedIssue relatedIssue in issue.IssueRelatedIssues.ToList())
{
IssueRelatedIssue newRelatedIssue = new IssueRelatedIssue
{
IssueId = relatedIssue.IssueId,
RelatedIssueId = relatedIssue.RelatedIssueId
};
originalIssue.IssueRelatedIssues.Add(newRelatedIssue);
//Add reverse issue if it doesnt exist
if (existingRelatedIssues.FirstOrDefault(x => x.IssueId == relatedIssue.RelatedIssueId && x.RelatedIssueId == relatedIssue.IssueId) == null)
{
IssueRelatedIssue reverseRelatedIssue = new IssueRelatedIssue
{
IssueId = relatedIssue.RelatedIssueId,
RelatedIssueId = relatedIssue.IssueId
};
cee.IssueRelatedIssues.Add(reverseRelatedIssue);
}
}
cee.Configuration.AutoDetectChangesEnabled = true;
}
示例2: SaveIssueRelatedKeyStakeholders
private void SaveIssueRelatedKeyStakeholders(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueRelatedKeyStakeholders()");
cee.DeleteWhere<IssueRelatedKeyStakeholder>(cee, x => x.IssueId == issue.Id);
cee.Configuration.AutoDetectChangesEnabled = false;
foreach (IssueRelatedKeyStakeholder stakeholder in issue.IssueRelatedKeyStakeholders)
{
originalIssue.IssueRelatedKeyStakeholders.Add(new IssueRelatedKeyStakeholder { RoleId = stakeholder.RoleId, IssueId = issue.Id });
}
cee.Configuration.AutoDetectChangesEnabled = true;
}
示例3: SaveCalibrationComponents
private void SaveCalibrationComponents(IEnumerable<CalibrationComponent> calibrationComponents)
{
bool isInsert = false;
using (CmsEntities cee = new CmsEntities())
{
foreach (var calibrationComponent in calibrationComponents)
{
CalibrationComponent match = (from x in cee.CalibrationComponents
where x.Id == calibrationComponent.Id
&& x.Id > 0
select x).FirstOrDefault();
if (match != null)
{
//Update Calibration Componet
cee.Entry(match).CurrentValues.SetValues(calibrationComponent);
}
else
{
isInsert = true;
match = new CalibrationComponent
{
InstrumentId = calibrationComponent.InstrumentId,
CalibrationComponentTypeId = calibrationComponent.CalibrationComponentTypeId,
Name = calibrationComponent.Name,
Ordinal = calibrationComponent.Ordinal,
NextInspectionDate = calibrationComponent.NextInspectionDate,
LastInspectedById = calibrationComponent.LastInspectedById,
LastInspectedDate = calibrationComponent.LastInspectedDate,
LastModifiedById = calibrationComponent.LastModifiedById,
LastModifiedDate = calibrationComponent.LastModifiedDate,
Description = calibrationComponent.Description,
Notes = calibrationComponent.Notes
};
//Add new Calibration Component
cee.CalibrationComponents.Add(match);
}
//delete all Calibration Component Attachments
cee.DeleteWhere<CalibrationComponentAttachment>(cee,x=>x.CalibrationComponentId == match.Id);
//Add current Calibration Component Attachments
foreach (var attachment in calibrationComponent.CalibrationComponentAttachments)
{
match.CalibrationComponentAttachments.Add(new CalibrationComponentAttachment {CalibrationComponentId = attachment.CalibrationComponentId, AttachmentId = attachment.AttachmentId});
}
foreach (var calibrationComponentPropertyValue in calibrationComponent.CalibrationComponentPropertyValues)
{
var qq = (from x in cee.CalibrationComponentPropertyValues
where x.Id == calibrationComponentPropertyValue.Id
select x).FirstOrDefault();
if (qq != null)
{
cee.Entry(qq).CurrentValues.SetValues(calibrationComponentPropertyValue);
}
else
{
cee.CalibrationComponentPropertyValues.Add(calibrationComponentPropertyValue);
}
}
cee.SaveChanges();
if (isInsert)
{
//https://jira.issgroup.com.au/browse/BODCMS-998
SendNewCalibrationComponentEmail(match);
}
}
}
}
示例4: SaveAccruals
public DbOperationResult SaveAccruals(List<FinancialAccrual> accruals, List<IssueFinancialOtherAccrual> otherAccruals, string projectDefinition, DateTime date)
{
var result = new DbOperationResult();
try
{
using (CmsEntities cee = new CmsEntities())
{
//Delete existing IssueFinancialOtherAccrual
cee.DeleteWhere<IssueFinancialOtherAccrual>(cee, x => x.ProjectDefinition == projectDefinition && x.Date == date);
//Save Accruals
foreach (var accrual in accruals)
{
var original = (from x in cee.FinancialAccruals where x.Id == accrual.Id select x).FirstOrDefault();
if (original == null)
{
cee.FinancialAccruals.Add(accrual);
}
else
{
cee.Entry(original).CurrentValues.SetValues(accrual);
}
}
//Save Other Accruals
foreach (var otherAccrual in otherAccruals)
{
var original = (from x in cee.IssueFinancialOtherAccruals where x.Id == otherAccrual.Id select x).FirstOrDefault();
if (original == null)
{
cee.IssueFinancialOtherAccruals.Add(otherAccrual);
}
else
{
cee.Entry(original).CurrentValues.SetValues(otherAccrual);
}
}
cee.SaveChanges();
}
result.HasErrors = false;
return result;
}
catch (DbEntityValidationException ex)
{
foreach (var validationErrors in ex.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
log.Error("", ex, "Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
}
}
return BuildOperationalErrorResults(ex);
}
catch (Exception ex)
{
log.Error("", ex, "Error occured in SaveAccruals()");
return BuildOperationalErrorResults(ex);
}
}
示例5: SaveIssueSystemReferences
private void SaveIssueSystemReferences(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueSystemReferences()");
//Delete
cee.DeleteWhere<SystemReference>(cee, x => x.IssueId == issue.Id);
foreach (SystemReference systemReference in issue.SystemReferences.ToList())
{
var sr = new SystemReference
{
IssueId = systemReference.IssueId,
SystemReferenceTypeId = systemReference.SystemReferenceTypeId,
Number = systemReference.Number,
Description = systemReference.Description,
EstValue = systemReference.EstValue,
ActualValue = systemReference.ActualValue,
FundingType = systemReference.FundingType
};
originalIssue.SystemReferences.Add(sr);
}
}
示例6: SaveRisks
private void SaveRisks(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveRisks()");
issue.CurrentlyAssignedToUser = null;
//Delete all existing risks that belongs to the issue
cee.DeleteWhere<IssueRisk>(cee, x => x.IssueId == issue.Id);
cee.Configuration.AutoDetectChangesEnabled = false;
foreach (IssueRisk item in issue.IssueRisks)
{
var newIssueRisk = new IssueRisk();
newIssueRisk.IssueId = item.IssueId;
newIssueRisk.RiskTypeId = item.RiskTypeId;
newIssueRisk.CategoryId = item.CategoryId;
newIssueRisk.RiskLikelihoodId = item.RiskLikelihoodId;
newIssueRisk.ConsequenceId = item.ConsequenceId;
newIssueRisk.RiskMatrixId = item.RiskMatrixId;
originalIssue.IssueRisks.Add(newIssueRisk);
}
cee.Configuration.AutoDetectChangesEnabled = true;
}
示例7: SaveIssueDistributionUsers
private void SaveIssueDistributionUsers(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueDistributionUsers()");
issue.CurrentlyAssignedToUser = null;
//Delete all existing users that belongs to the issue
cee.DeleteWhere<IssueDistributionUser>(cee, x => x.IssueId == issue.Id);
cee.Configuration.AutoDetectChangesEnabled = false;
foreach (IssueDistributionUser item in issue.IssueDistributionUsers)
{
var newIssueDistUser = new IssueDistributionUser();
newIssueDistUser.UserId = item.UserId;
newIssueDistUser.IssueId = item.IssueId;
newIssueDistUser.AllowDeletion = item.AllowDeletion;
originalIssue.IssueDistributionUsers.Add(newIssueDistUser);
}
cee.Configuration.AutoDetectChangesEnabled = true;
}
示例8: SaveIssueRelatedPipes
private void SaveIssueRelatedPipes(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueRelatedPipes()");
//Delete
cee.DeleteWhere<IssueRelatedPipe>(cee, x => x.IssueId == issue.Id);
//Save
foreach (IssueRelatedPipe pipeIssue in issue.IssueRelatedPipes.ToList())
{
IssueRelatedPipe newIssueRelatedPipe = new IssueRelatedPipe
{
IssueId = pipeIssue.IssueId,
PipeId = pipeIssue.PipeId,
Notes = pipeIssue.Notes
};
if (pipeIssue.Implemented)
{
if (pipeIssue.ImplementedById.HasValue)
{
newIssueRelatedPipe.Implemented = pipeIssue.Implemented;
newIssueRelatedPipe.ImplementedById = pipeIssue.ImplementedById;
newIssueRelatedPipe.ImplementedDate = pipeIssue.ImplementedDate;
}
}
if (pipeIssue.Tested)
{
if (pipeIssue.TestedById != null)
{
newIssueRelatedPipe.Tested = pipeIssue.Tested;
newIssueRelatedPipe.TestedById = pipeIssue.TestedById;
newIssueRelatedPipe.TestedDate = pipeIssue.TestedDate;
}
}
originalIssue.IssueRelatedPipes.Add(newIssueRelatedPipe);
}
}
示例9: SaveIssueAssignedCategories
private void SaveIssueAssignedCategories(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueAssignedCategories()");
//Delete IssueAssignedCategories
cee.DeleteWhere<IssueAssignedCategory>(cee, x => x.IssueId == issue.Id);
var ht = new Hashtable();
cee.Configuration.AutoDetectChangesEnabled = false;
//Save IssueAssignedCategories
foreach (IssueAssignedCategory issueAssignedCategory in issue.IssueAssignedCategories.ToList())
{
string key = issueAssignedCategory.IssueId + ":" + issueAssignedCategory.IssueCategoryId;
//stops accidental adding duplicate categories to an Issue.
if (!ht.ContainsKey(key))
{
ht.Add(key, issueAssignedCategory);
int categoryId = issueAssignedCategory.IssueCategoryId;
issueAssignedCategory.Issue = null;
issueAssignedCategory.IssueId = issue.Id;
issueAssignedCategory.IssueCategory = null;
issueAssignedCategory.IssueCategoryId = categoryId;
originalIssue.IssueAssignedCategories.Add(issueAssignedCategory);
}
}
cee.Configuration.AutoDetectChangesEnabled = true;
}
示例10: SaveIssueCloseouts
private void SaveIssueCloseouts(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueCloseouts()");
if (issue.IssueCloseouts.Count == 0) return;
cee.DeleteWhere<IssueCloseout>(cee, x => x.IssueId == issue.Id);
cee.Configuration.AutoDetectChangesEnabled = false;
foreach (IssueCloseout closeout in issue.IssueCloseouts)
{
closeout.Issue = null;
closeout.IssueCategory = null;
if (closeout.Verifier != null)
{
int? byId = closeout.VerifierId;
closeout.Verifier = null;
closeout.VerifierId = byId;
}
originalIssue.IssueCloseouts.Add(closeout);
}
cee.Configuration.AutoDetectChangesEnabled = true;
}
示例11: SaveIssueAreas
private void SaveIssueAreas(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueAreas()");
cee.DeleteWhere<IssueArea>(cee, x => x.IssueId == issue.Id);
cee.Configuration.AutoDetectChangesEnabled = false;
//Save IssueAssignedCategories
foreach (IssueArea issueArea in issue.IssueAreas)
{
originalIssue.IssueAreas.Add(new IssueArea { AreaId = issueArea.AreaId, IssueId = issue.Id });
}
cee.Configuration.AutoDetectChangesEnabled = true;
}
示例12: SaveIssueApprovals
private void SaveIssueApprovals(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueApprovals()");
if (issue.IssueApprovals.Count == 0) return;
int issueId = issue.Id;
////delete...
cee.DeleteWhere<IssueApproval>(cee, x => x.IssueId == issue.Id);
var ht = new Hashtable(); //for some reason we are sending back too many approvals - hack stop for now...
cee.Configuration.AutoDetectChangesEnabled = false;
foreach (IssueApproval approval in issue.IssueApprovals)
{
var newApproval = new IssueApproval();
if (!ht.ContainsKey(approval.IssueCategoryId))
{
ht.Add(approval.IssueCategoryId, approval.IssueCategoryId);
newApproval.IssueCategoryId = approval.IssueCategoryId;
newApproval.IssueId = issueId;
if (approval.Approver != null)
{
newApproval.ApproverId = approval.ApproverId;
newApproval.Approved = approval.Approved;
newApproval.Date = approval.Date;
}
originalIssue.IssueApprovals.Add(newApproval);
}
}
//issue.IssueApprovals.Clear();
cee.Configuration.AutoDetectChangesEnabled = true;
}
示例13: SaveIssueStatus
public IssueStatus SaveIssueStatus(IssueStatus issueStatus)
{
IssueStatus issueStatusToUpdate = null;
try
{
using (var cee = new CmsEntities())
{
//Check if the object exist
issueStatusToUpdate = (from x in cee.IssueStatuses where x.Id == issueStatus.Id select x).FirstOrDefault();
int issueStatusId = issueStatus.Id;
if (issueStatusToUpdate == null)
{
//Create new Issue Status
issueStatusToUpdate = new IssueStatus
{
Name = issueStatus.Name,
Ordinal = issueStatus.Ordinal,
Code = issueStatus.Name.Replace(" ", ""),
IsActive = issueStatus.IsActive,
DisableWorkflow = issueStatus.DisableWorkflow
};
cee.IssueStatuses.Add(issueStatusToUpdate);
cee.SaveChanges();
issueStatusId = issueStatusToUpdate.Id;
}
else
{
//Update existing Status
issueStatusToUpdate.Name = issueStatus.Name;
issueStatusToUpdate.Ordinal = issueStatus.Ordinal;
issueStatusToUpdate.IsActive = issueStatus.IsActive;
issueStatusToUpdate.DisableWorkflow = issueStatus.DisableWorkflow;
//Delete Rules
cee.DeleteWhere<StatusTypeRule>(cee, x => x.StatusId == issueStatus.Id);
//Delete Issue Control Statuses
cee.DeleteWhere<StatusTypeEnabledControl>(cee, x => x.IssueStatusId == issueStatus.Id);
//Delete Issue Available Statuses
cee.DeleteWhere<StatusTypeAvailableStatus>(cee, x => x.StatusId == issueStatus.Id);
}
//Update Rules
foreach (StatusTypeRule issueStatusRule in issueStatus.StatusTypeRules)
{
StatusTypeRule newStatusTypeRule = new StatusTypeRule
{
RuleName = issueStatusRule.RuleName,
StatusId = issueStatusId,
IssueTypeId = issueStatusRule.IssueTypeId
};
issueStatusToUpdate.StatusTypeRules.Add(newStatusTypeRule);
}
//Update Issue Control Statuses
foreach (StatusTypeEnabledControl issueStatuesControl in issueStatus.StatusTypeEnabledControls)
{
StatusTypeEnabledControl newStatusTypeEnabledControl = new StatusTypeEnabledControl
{
IssueStatusId = issueStatusId,
IssueTypeId = issueStatuesControl.IssueTypeId,
IssueTabControlId = issueStatuesControl.IssueTabControlId
};
issueStatusToUpdate.StatusTypeEnabledControls.Add(newStatusTypeEnabledControl);
}
//Update Issue Available Statuses
foreach (StatusTypeAvailableStatus issueAvailableStatus in issueStatus.StatusTypeAvailableStatuses)
{
StatusTypeAvailableStatus newStatusTypeAvailableStatus = new StatusTypeAvailableStatus
{
StatusId = issueStatusId,
IssueTypeId = issueAvailableStatus.IssueTypeId,
AvailableStatusId = issueAvailableStatus.AvailableStatusId,
IsEnabled = issueAvailableStatus.IsEnabled,
IsVisible = issueAvailableStatus.IsVisible
};
issueStatusToUpdate.StatusTypeAvailableStatuses.Add(newStatusTypeAvailableStatus);
}
cee.SaveChanges();
}
}
catch (DbEntityValidationException ex)
{
foreach (var validationErrors in ex.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
log.Error("", ex, "Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
}
}
}
catch (Exception ex)
{
log.Error("", ex, "Error in SaveIssueStatus()");
//.........这里部分代码省略.........
示例14: SaveIssueRelatedOverrides
private void SaveIssueRelatedOverrides(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueRelatedOverrides()");
//Delete
cee.DeleteWhere<IssueRelatedOverride>(cee, x => x.IssueId == issue.Id);
cee.Configuration.AutoDetectChangesEnabled = false;
foreach (IssueRelatedOverride relatedOverride in issue.IssueRelatedOverrides.ToList())
{
var newRelatedOverride = new IssueRelatedOverride
{
IssueId = relatedOverride.IssueId,
InterlockId = relatedOverride.InterlockId,
Notes = relatedOverride.Notes,
TargetRemovalDate = relatedOverride.TargetRemovalDate
};
if (relatedOverride.RemovedByUser != null && relatedOverride.RemovedById.HasValue)
{
newRelatedOverride.RemovedById = relatedOverride.RemovedById;
}
if (relatedOverride.AppliedByUser != null && relatedOverride.AppliedById.HasValue)
{
newRelatedOverride.AppliedById = relatedOverride.AppliedById;
}
if (relatedOverride.Removed)
{
if (relatedOverride.RemovedById.HasValue)
{
newRelatedOverride.Removed = true;
newRelatedOverride.RemovedById = relatedOverride.RemovedById;
newRelatedOverride.RemovedDate = relatedOverride.RemovedDate;
}
}
else
{
newRelatedOverride.Removed = false;
}
if (relatedOverride.Applied)
{
if (relatedOverride.AppliedById.HasValue)
{
newRelatedOverride.Applied = true;
newRelatedOverride.AppliedById = relatedOverride.AppliedById;
newRelatedOverride.AppliedDate = relatedOverride.AppliedDate;
}
}
else
{
newRelatedOverride.Applied = false;
}
originalIssue.IssueRelatedOverrides.Add(newRelatedOverride);
cee.Configuration.AutoDetectChangesEnabled = true;
}
}
示例15: SaveIssueFinancials
private void SaveIssueFinancials(Issue issue, Issue originalIssue, CmsEntities cee)
{
log.Verbose("SaveIssueFinancials()");
//Delete SaveIssueFinancials
cee.DeleteWhere<IssueFinancial>(cee, x => x.IssueId == issue.Id);
cee.Configuration.AutoDetectChangesEnabled = false;
//Save SaveIssueFinancials
foreach (IssueFinancial issueFinancial in issue.IssueFinancials.ToList())
{
var newFinancial = new IssueFinancial
{
IssueId = issue.Id,
Date = issueFinancial.Date,
Budget = issueFinancial.Budget,
Baseline = issueFinancial.Baseline,
Forecast = issueFinancial.Forecast,
Actual = issueFinancial.Actual,
Accrual = issueFinancial.Accrual,
ActualVsBaselineVarianceCodeId = issueFinancial.ActualVsBaselineVarianceCodeId,
ActualVsForecastVarianceCodeId = issueFinancial.ActualVsForecastVarianceCodeId,
ActualVsBaselineNote = issueFinancial.ActualVsBaselineNote,
ActualVsForecastNote = issueFinancial.ActualVsForecastNote,
LastModifiedDate = issueFinancial.LastModifiedDate,
LastModifiedUserId = issueFinancial.LastModifiedUserId,
ForecastLastModifiedDate = issueFinancial.ForecastLastModifiedDate,
ForecastLastModifiedUserId = issueFinancial.ForecastLastModifiedUserId,
ActualsOpex = issueFinancial.ActualsOpex,
ActualsCapex = issueFinancial.ActualsCapex,
ForecastV1 = issueFinancial.ForecastV1,
ForecastV2 = issueFinancial.ForecastV2,
ForecastV3 = issueFinancial.ForecastV3
};
originalIssue.IssueFinancials.Add(newFinancial);
}
cee.Configuration.AutoDetectChangesEnabled = true;
}