当前位置: 首页>>代码示例>>C#>>正文


C# ServiceContext.UpdateObject方法代码示例

本文整理汇总了C#中ServiceContext.UpdateObject方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceContext.UpdateObject方法的具体用法?C# ServiceContext.UpdateObject怎么用?C# ServiceContext.UpdateObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceContext的用法示例。


在下文中一共展示了ServiceContext.UpdateObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Notify

        public void Notify(MessageContracts.StockNotifyRequestMessage request)
        {
            using (OrganizationServiceProxy proxy = CRMHelper.Connect())
            {
                ServiceContext context = new ServiceContext(proxy);

                foreach(StockItemDataContract item in request.Items)
                {
                    bool add = false;

                    new_stock record = (from a in context.new_stockSet
                                           where a.new_vinnumber == item.Stock.new_vinnumber
                                           select a).FirstOrDefault();

                    if(record == null)
                    {
                        add = true;

                        record = new new_stock();
                    }

                    record.new_internalvehiclenumber = item.Stock.new_internalvehiclenumber;
                    record.new_vinnumber = item.Stock.new_vinnumber;
                    record.new_enginenumber = item.Stock.new_enginenumber;
                    record.new_sapvehiclemodelcode = item.Stock.new_sapvehiclemodelcode;
                    record.new_plantsap = item.Stock.new_plantsap;
                    record.new_storagelocation = item.Stock.new_storagelocation;
                    record.new_stockvalue = item.Stock.new_stockvalue;
                    record.new_status = item.Stock.new_status;
                    record.new_vehicleguid = item.Stock.new_vehicleguid;

                    if(add)
                        context.AddObject(record);
                    else
                        context.UpdateObject(record);
                }

                context.SaveChanges();
            }
        }
开发者ID:britehouse,项目名称:toyota-tsusho-new,代码行数:40,代码来源:StockService.cs

示例2: Notify


//.........这里部分代码省略.........

                    record.new_client = item.Invoice.new_client;

                    if (contact != null)
                        record.CustomerId = contact.ToEntityReference();

                    if (order != null)
                        record.SalesOrderId = order.ToEntityReference();

                    record.new_precedingdocument = item.Invoice.new_precedingdocument;

                    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)
开发者ID:britehouse,项目名称:toyota-tsusho-new,代码行数:67,代码来源:OrderService.cs

示例3: UpdateSuccesfullRead

        private void UpdateSuccesfullRead(ServiceContext context, TimeoutManagerDataEntity read)
        {
            if (read == null)
            {
                read = new TimeoutManagerDataEntity(Configure.EndpointName, string.Empty){
                               LastSuccessfullRead = DateTime.UtcNow
                           };

                context.AddObject(ServiceContext.TimeoutManagerDataEntityTableName, read);
            }
            else
            {
                read.LastSuccessfullRead = DateTime.UtcNow;
                context.UpdateObject(read);
            }

            context.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);
        }
开发者ID:remogloor,项目名称:NServiceBus,代码行数:18,代码来源:TimeoutPersister.cs


注:本文中的ServiceContext.UpdateObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。