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


C# Database.UpdateAsync方法代码示例

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


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

示例1: DisableAsync

        public async Task DisableAsync(Script script)
        {
            Assert.NotNull(script);

            using (var database = new Database("ConnectionString"))
            {
                script.IsEnabled = false;
                await database.UpdateAsync(script, new[] { "IsEnabled" });
            }
        }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:10,代码来源:ScriptRepository.cs

示例2: SaveAsync

 public async Task SaveAsync(Room room)
 {
     using (var database = new Database("ConnectionString"))
     {
         if (room.Id == Guid.Empty)
         {
             room.Id = Guid.NewGuid();
             await database.InsertAsync(room);
         }
         else
         {
             await database.UpdateAsync(room);
         }
     }
 }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:15,代码来源:RoomRepository.cs

示例3: SaveAsync

 public async Task SaveAsync(RoomScriptGroup group)
 {
     using (var database = new Database("ConnectionString"))
     {
         if (group.Id == Guid.Empty)
         {
             group.Id = Guid.NewGuid();
             await database.InsertAsync(group);
         }
         else
         {
             await database.UpdateAsync(group);
         }
     }
 }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:15,代码来源:RoomScriptGroupRepository.cs

示例4: SaveAsync

        public async Task SaveAsync(string gatewayName, DeviceBase device)
        {
            var properties = GetProperties(device);

            var dto = new DeviceDto
            {
                Gateway = gatewayName,
                Id = $"{gatewayName}.{device.Id}",
                Name = device.Name,
                Properties = JsonConvert.SerializeObject(properties)
            };

            using (var database = new Database("ConnectionString"))
            {
                var result = await database.UpdateAsync("Device", "Id", dto, dto.Id, new[] {"Gateway", "Name", "Properties"});

                if (result == 1)
                {
                    return;
                }

                await database.InsertAsync("Device", "Id", false, dto);
            }
        }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:24,代码来源:DevicePersistingService.cs

示例5: SaveVariables

        private async Task SaveVariables()
        {
            if (_isInMemory)
            {
                return;
            }

            using (var database = new Database("ConnectionString"))
            {
                while (_variablesToSave.Count > 0)
                {
                    var variable = _variablesToSave.Take();

                    var persistedVariable = new PersistedVariable
                    {
                        Name = variable.Name,
                        DataType = variable.Value.GetType().Name,
                        Value = variable.Value.ToString()
                    };

                    if (_persistedVariables.Contains(variable.Name))
                    {
                        await database.UpdateAsync("Variable", "Name", persistedVariable, variable.Name, new[] {"Value"});
                    }
                    else
                    {
                        await database.InsertAsync("Variable", "Name", false, persistedVariable);
                        _persistedVariables.Add(variable.Name);
                    }
                }
            }
        }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:32,代码来源:VariablePersistingService.cs

示例6: UpdateAsync

        private async Task UpdateAsync(Script script)
        {
            Assert.NotNull(script);

            using (var database = new Database("ConnectionString"))
            {
                await database.UpdateAsync(script, new[] {"Name", "JavaScript", "IsEnabled"});
            }
        }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:9,代码来源:ScriptRepository.cs

示例7: StoreHL7

        async Task StoreHL7(Database db, XDocument xDoc, string hl7, string fileName)
        {
            var messageControlId = (from elem in xDoc.Descendants("MSH.10") select elem.Value).FirstOrDefault().ToDecimal();

            var exists = await db.ExistsAsync<HL7>("MessageControlId = @0", messageControlId);

            var record = new HL7();
            record.MessageControlId = messageControlId;
            record.MessageTimeStamp = (from elem in xDoc.Descendants("MSH.7") select elem.Value).FirstOrDefault().ToDatetime("yyyyMMddHHmmss", new DateTime(3000, 1, 1));
            record.MessageType = (from elem in xDoc.Descendants("MSH.9.1") select elem.Value).FirstOrDefault();
            record.EventType = (from elem in xDoc.Descendants("MSH.9.2") select elem.Value).FirstOrDefault();
            record.Message = hl7;
            record.FileName = fileName;

            if (record.MessageControlId == decimal.Zero || record.MessageType.IsNullOrEmpty() || record.EventType.IsNullOrEmpty())
                return;

            if (exists)
                await db.UpdateAsync("HL7v23.dbo.HL7", "MessageControlId", record);
            else
                await db.InsertAsync("HL7v23.dbo.HL7", "MessageControlId", false, record);

            if (record.MessageType == "MFN")
                await StoreMFN(db, xDoc, exists);
            else if (record.MessageType == "ADT")
                await StoreADT(db, xDoc, exists);
            else if (record.MessageType == "BAR")
                await StoreBAR(db, xDoc, exists);
            else
            {
                var message = string.Format("Need to store unsupported Message with MessageType {0}: {1}", record.MessageType, hl7);
                LogException(message, new Exception(message), null);   
            }

            await db.ExecuteAsync(@"update ZISv21.dbo.LastProcessedMessage
set MessageControlId = @0 
where [application] = @1 and MessageControlId < @0", messageControlId, "HL7v23");
        }
开发者ID:pjlammertyn,项目名称:PollerQueue,代码行数:38,代码来源:HL7FilePoller.cs

示例8: StoreBAR

        async Task StoreBAR(Database db, XDocument xDoc, bool exists)
        {
            var messageControlId = (from elem in xDoc.Descendants("MSH.10") select elem.Value).FirstOrDefault();

            var record = new BAR();
            record.MessageControlId = messageControlId;
            record.PatientId = (from elem in xDoc.Descendants("PID.3") select elem.Value).FirstOrDefault();
            record.VisitNumber = (from elem in xDoc.Descendants("PV1.19.1") select elem.Value).FirstOrDefault();
            var insuranceCompanyId = (from elem in xDoc.Descendants("IN1.3") select elem.Value).FirstOrDefault();
            if (!insuranceCompanyId.IsNullOrEmpty())
            {
                if (insuranceCompanyId.Length == 7)
                {
                    record.PlanId = insuranceCompanyId.Substring(0, 1);
                    record.InsuranceCompanyNumber = insuranceCompanyId.Substring(1, 6);
                }
                else //mutualities
                {
                    record.PlanId = "2"; //for mutualities set planId to 2
                    record.InsuranceCompanyNumber = insuranceCompanyId;
                }
            }

            if (exists)
                await db.UpdateAsync("HL7v23.dbo.BAR", "MessageControlId", record);
            else
                await db.InsertAsync("HL7v23.dbo.BAR", "MessageControlId", false, record);
        }
开发者ID:pjlammertyn,项目名称:PollerQueue,代码行数:28,代码来源:HL7FilePoller.cs

示例9: StoreMFN

        async Task StoreMFN(Database db, XDocument xDoc, bool exists)
        {
            var messageControlId = (from elem in xDoc.Descendants("MSH.10") select elem.Value).FirstOrDefault().ToDecimal();

            var record = new MFN();
            record.MessageControlId = messageControlId;

            record.DoctorNumber = (from elem in xDoc.Descendants("STF.1") select elem.Value).FirstOrDefault().ToDecimal();

            var insuranceCompanyId = (from elem in xDoc.Descendants("IN1.3") select elem.Value).FirstOrDefault();
            if (!insuranceCompanyId.IsNullOrEmpty())
            {
                if (insuranceCompanyId.Length == 7)
                {
                    record.PlanId = insuranceCompanyId.ToCharArray(0, 1)[0];
                    record.InsuranceCompanyNumber = insuranceCompanyId.Substring(1, 6).ToDecimal();
                }
                else //mutualities
                {
                    record.PlanId = '2'; //for mutualities set planId to 2
                    record.InsuranceCompanyNumber = insuranceCompanyId.ToDecimal();
                }
            }

            if (exists)
                await db.UpdateAsync("HL7v23.dbo.MFN", "MessageControlId", record);
            else
                await db.InsertAsync("HL7v23.dbo.MFN", "MessageControlId", false, record);
        }
开发者ID:pjlammertyn,项目名称:PollerQueue,代码行数:29,代码来源:HL7FilePoller.cs

示例10: StoreADT

        async Task StoreADT(Database db, XDocument xDoc, bool exists)
        {
            var messageControlId = (from elem in xDoc.Descendants("MSH.10") select elem.Value).FirstOrDefault().ToDecimal();

            var record = new ADT();
            record.MessageControlId = messageControlId;
            record.EventTimeStamp = (from elem in xDoc.Descendants("EVN.6") select elem.Value).FirstOrDefault().ToDatetime("yyyyMMddHHmm",
                (from elem in xDoc.Descendants("PV1.44") select elem.Value).FirstOrDefault().ToDatetime("yyyyMMddHHmm",
                    new DateTime(3000, 1, 1)));
            record.PatientId = (from elem in xDoc.Descendants("PID.3") select elem.Value).FirstOrDefault().ToDecimal();
            record.VisitNumber = (from elem in xDoc.Descendants("PV1.19.1") select elem.Value).FirstOrDefault().ToDecimal();
            record.PreadmitNumber = (from elem in xDoc.Descendants("PV1.5") select elem.Value).FirstOrDefault();
            record.AdmissionUnitNumber = (from elem in xDoc.Descendants("PV1.10") select elem.Value).FirstOrDefault().ToDecimal();
            record.CampusCode = (from elem in xDoc.Descendants("PV1.3.4") select elem.Value).FirstOrDefault();
            record.NursingUnitNumber = (from elem in xDoc.Descendants("PV1.3.1") select elem.Value).FirstOrDefault().ToDecimal();
            record.RoomNumber = (from elem in xDoc.Descendants("PV1.3.2") select elem.Value).FirstOrDefault().ToDecimal();
            record.BedNumber = (from elem in xDoc.Descendants("PV1.3.3") select elem.Value).FirstOrDefault().Maybe(s => s.PadLeft(2, '0'));
            record.DoctorNumber = (from elem in xDoc.Descendants("PV1.17.1") select elem.Value).FirstOrDefault().ToDecimal();
            record.FamilyName = (from elem in xDoc.Descendants("PID.5.1") select elem.Value).FirstOrDefault();
            record.FirstName = (from elem in xDoc.Descendants("PID.5.2") select elem.Value).FirstOrDefault();
            record.PreviousCampusCode = (from elem in xDoc.Descendants("PV1.6.4") select elem.Value).FirstOrDefault();
            record.PreviousNursingUnitNumber = (from elem in xDoc.Descendants("PV1.6.1") select elem.Value).FirstOrDefault().ToDecimal();
            record.PreviousRoomNumber = (from elem in xDoc.Descendants("PV1.6.2") select elem.Value).FirstOrDefault().ToDecimal();
            record.PreviousBedNumber = (from elem in xDoc.Descendants("PV1.6.3") select elem.Value).FirstOrDefault().Maybe(s => s.PadLeft(2, '0'));

            if (exists)
                await db.UpdateAsync("HL7v23.dbo.ADT", "MessageControlId", record);
            else
                await db.InsertAsync("HL7v23.dbo.ADT", "MessageControlId", false, record);
        }
开发者ID:pjlammertyn,项目名称:PollerQueue,代码行数:30,代码来源:HL7FilePoller.cs


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