标签:
select
from
where
in
into
join
on
equals
orderby
descending
DefaultIfEmpty()
thenby
submitChanges();
DeleteAllOnSubmit()
InsertAllOnSubmit()
/// <summary>报销单是否被增值税引用 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool IsRefWithholding(string id) { var isRefWithholding = (from wh in _dataContext.Withholdings join clp in _dataContext.ClaimSheetBaseInProjects on wh.ClaimSheetBaseInProjectId equals clp.Id join cl in _dataContext.ClaimSheetBases on clp.bxdId equals cl.Id where cl.Id == id select wh).Count() > 0; return isRefWithholding; }
public void UpdateClaimSheetBaseForFrozen(ClaimSheetBaseDto item) { _dataContext.CommandTimeout = 180; if (item != null) { var claimSheetBase = _dataContext.ClaimSheetBases.Single(a => a.Id.Equals(item.Id)); claimSheetBase.IsFrozen = item.IsFrozen; claimSheetBase.FrozenCode = item.FrozenCode; _dataContext.SubmitChanges(); } }
public void DelectProjectPay(ClaimSheetBaseDto item) { if (item.IsMulPay.Equals(true)) { var projectPay = _dataContext.ProjectPay.Where(o => o.ClaimSheetBaseId == item.Id); if (item.PaymentByReverseDto != null) { _dataContext.ProjectPay.DeleteAllOnSubmit(projectPay); } } }
增加用例:
/// <summary>添加附件 /// 先删除后增加 /// </summary> /// <param name="claimSheetBaseId"></param> /// <param name="?"></param> /// <returns></returns> public bool AddAttachmentWB(ClaimSheetBaseDto item) { if (item.AttachmentDtos != null) { var attachments = _dataContext.AttachmentWB.Where(a => a.ClaimSheetBaseId.Equals(item.Id)); if (attachments != null && attachments.Count() > 0) { _dataContext.AttachmentWB.DeleteAllOnSubmit(attachments); } var attachmentDtos = new List<AttachmentWB>(); foreach (var attachment in item.AttachmentDtos) { attachmentDtos.Add(RePackAttachment(attachment)); } _dataContext.AttachmentWB.InsertAllOnSubmit(attachmentDtos); } _dataContext.SubmitChanges(); return true; }
标签:
原文地址:http://www.cnblogs.com/jacketlin/p/5752275.html