本文整理汇总了C#中ServiceContext.DeleteObject方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceContext.DeleteObject方法的具体用法?C# ServiceContext.DeleteObject怎么用?C# ServiceContext.DeleteObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceContext
的用法示例。
在下文中一共展示了ServiceContext.DeleteObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Notify
//.........这里部分代码省略.........
if (salesOffice != null)
record.new_salesoffice = salesOffice.ToEntityReference();
if(plant != null)
record.new_plant = plant.ToEntityReference();
record.new_customeradviser = item.Invoice.new_customeradviser;
record.new_billingdate = item.Invoice.new_billingdate;
record.new_licenseplatenumber = item.Invoice.new_licenseplatenumber;
record.new_country = item.Invoice.new_country;
record.new_counterreading = item.Invoice.new_counterreading;
record.new_counterunit = item.Invoice.new_counterunit;
record.new_orderstatus = item.Invoice.new_orderstatus;
record.new_netvalue = item.Invoice.new_netvalue;
record.new_vehicleguid = item.Invoice.new_vehicleguid;
if (invoiceType != null)
record.new_invoicetype = invoiceType.ToEntityReference();
if (add)
context.AddObject(record);
else
context.UpdateObject(record);
//Invoice Detail
//We will nowdelete all line item s and readd them
//if we do not do this we will get duplicate records.
if (record.invoice_details != null)
{
foreach (InvoiceDetail detail in record.invoice_details)
context.DeleteObject(detail);
}
foreach (InvoiceDetail lineItem in item.InvoiceDetails)
{
InvoiceDetail detail = new InvoiceDetail();
//new_material
new_modelsalescode material = null;
if(detail.new_material != null)
{
material = (from m in context.new_modelsalescodeSet
where m.new_name == lineItem.new_material.Name
select m).FirstOrDefault();
}
//Plant
Territory detailPlant = null;
if (lineItem.new_plant != null)
{
entity = (from p in context.CreateQuery("territory")
where p["new_sapcode"] == lineItem.new_plant.Name
select p).FirstOrDefault();
if (entity != null)
detailPlant = entity.ToEntity<Territory>();
}
//Populate Invoice Detail
示例2: TryRemove
public bool TryRemove(string timeoutId, out TimeoutData timeoutData)
{
timeoutData = null;
var context = new ServiceContext(account.TableEndpoint.ToString(), account.Credentials);
try
{
TimeoutDataEntity timeoutDataEntity;
if (!TryGetTimeoutData(context, timeoutId, string.Empty, out timeoutDataEntity))
{
return false;
}
timeoutData = new TimeoutData
{
Destination = Address.Parse(timeoutDataEntity.Destination),
SagaId = timeoutDataEntity.SagaId,
State = Download(timeoutDataEntity.StateAddress),
Time = timeoutDataEntity.Time,
CorrelationId = timeoutDataEntity.CorrelationId,
Id = timeoutDataEntity.RowKey,
OwningTimeoutManager = timeoutDataEntity.OwningTimeoutManager,
Headers = Deserialize(timeoutDataEntity.Headers)
};
TimeoutDataEntity timeoutDataEntityBySaga;
if (TryGetTimeoutData(context, timeoutDataEntity.SagaId.ToString(), timeoutId, out timeoutDataEntityBySaga))
{
context.DeleteObject(timeoutDataEntityBySaga);
}
TimeoutDataEntity timeoutDataEntityByTime;
if (TryGetTimeoutData(context, timeoutDataEntity.Time.ToString(partitionKeyScope), timeoutId, out timeoutDataEntityByTime))
{
context.DeleteObject(timeoutDataEntityByTime);
}
RemoveState(timeoutDataEntity.StateAddress);
context.DeleteObject(timeoutDataEntity);
context.SaveChanges();
}
catch(Exception ex)
{
Logger.Debug(string.Format("Failed to clean up timeout {0}", timeoutId), ex);
}
return true;
}
示例3: MigrateExistingTimeouts
private void MigrateExistingTimeouts(ServiceContext context)
{
var existing = (from c in context.TimeoutData
where c.PartitionKey == "TimeoutData"
select c).ToList();
foreach(var timeout in existing)
{
TimeoutDataEntity timeoutDataEntity;
if (!TryGetTimeoutData(context, timeout.Time.ToString(partitionKeyScope), timeout.RowKey, out timeoutDataEntity))
context.AddObject(ServiceContext.TimeoutDataEntityTableName,
new TimeoutDataEntity(timeout.Time.ToString(partitionKeyScope), timeout.RowKey)
{
Destination = timeout.Destination,
SagaId = timeout.SagaId,
StateAddress = timeout.RowKey,
Time = timeout.Time,
CorrelationId = timeout.CorrelationId,
OwningTimeoutManager = timeout.OwningTimeoutManager
});
if (!TryGetTimeoutData(context, timeout.SagaId.ToString(), timeout.RowKey, out timeoutDataEntity))
context.AddObject(ServiceContext.TimeoutDataEntityTableName,
new TimeoutDataEntity(timeout.SagaId.ToString(), timeout.RowKey)
{
Destination = timeout.Destination,
SagaId = timeout.SagaId,
StateAddress = timeout.RowKey,
Time = timeout.Time,
CorrelationId = timeout.CorrelationId,
OwningTimeoutManager = timeout.OwningTimeoutManager
});
if (!TryGetTimeoutData(context, timeout.RowKey, string.Empty, out timeoutDataEntity))
context.AddObject(ServiceContext.TimeoutDataEntityTableName,
new TimeoutDataEntity(timeout.RowKey, string.Empty)
{
Destination = timeout.Destination,
SagaId = timeout.SagaId,
StateAddress = timeout.RowKey,
Time = timeout.Time,
CorrelationId = timeout.CorrelationId,
OwningTimeoutManager = timeout.OwningTimeoutManager
});
context.DeleteObject(timeout);
context.SaveChanges();
}
}
示例4: RemoveTimeoutBy
public void RemoveTimeoutBy(Guid sagaId)
{
var context = new ServiceContext(account.TableEndpoint.ToString(), account.Credentials);
try
{
var results = (from c in context.TimeoutData
where c.PartitionKey == sagaId.ToString()
select c).ToList();
foreach (var timeoutDataEntityBySaga in results)
{
RemoveState(timeoutDataEntityBySaga.StateAddress);
TimeoutDataEntity timeoutDataEntityByTime;
if (TryGetTimeoutData(context, timeoutDataEntityBySaga.Time.ToString(partitionKeyScope), timeoutDataEntityBySaga.RowKey, out timeoutDataEntityByTime))
context.DeleteObject(timeoutDataEntityByTime);
TimeoutDataEntity timeoutDataEntity;
if (TryGetTimeoutData(context, timeoutDataEntityBySaga.RowKey, string.Empty, out timeoutDataEntity))
context.DeleteObject(timeoutDataEntity);
context.DeleteObject(timeoutDataEntityBySaga);
}
context.SaveChanges();
}
catch(Exception ex)
{
Logger.Debug(string.Format("Failed to clean up timeouts for saga {0}", sagaId), ex);
}
}