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


C# Database.ExecuteAsync方法代码示例

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


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

示例1: CreateDbAsync

		public async Task CreateDbAsync()
		{
			db = new Database(_connectionStringName);
			var all = Utils.LoadTextResource(string.Format("AsyncPoco.Tests.{0}_init.sql", _connectionStringName));
			foreach(var sql in all.Split(';').Select(s => s.Trim()).Where(s => s.Length > 0))
				await db.ExecuteAsync(sql);
		}
开发者ID:tmenier,项目名称:AsyncPoco,代码行数:7,代码来源:Tests.cs

示例2: CreateDbAsync

		public Task CreateDbAsync()
		{
			db = new Database(_connectionStringName);
			//await db.OpenSharedConnectionAsync();		// <-- Wow, this is crucial to getting SqlCE to perform.
														// true, but it was causing AsyncPoco tests pass when they should have failed
			return db.ExecuteAsync(Utils.LoadTextResource(string.Format("AsyncPoco.Tests.{0}_init.sql", _connectionStringName)));
		}
开发者ID:kevinsbennett,项目名称:AsyncPoco,代码行数:7,代码来源:Tests.cs

示例3: RemoveDeviceFromRoomAsync

 public async Task RemoveDeviceFromRoomAsync(string gatewayName, string deviceId)
 {
     using (var database = new Database("ConnectionString"))
     {
         const string sql = "delete from RoomDevice where Gateway = @0 and Id = @1)";
         await database.ExecuteAsync(sql, gatewayName, deviceId);
     }
 }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:8,代码来源:RoomDeviceService.cs

示例4: CreateDbAsync

		public async Task CreateDbAsync()
		{
			db = new Database(_connectionStringName);
			await db.ExecuteAsync(@"

DROP TABLE IF EXISTS posts;
DROP TABLE IF EXISTS authors;

CREATE TABLE posts (
	id				bigint AUTO_INCREMENT NOT NULL,
	title			varchar(127) NOT NULL,
	author			bigint NOT NULL,
	PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE authors (
	id				bigint AUTO_INCREMENT NOT NULL,
	name			varchar(127) NOT NULL,
	PRIMARY KEY (id)
) ENGINE=INNODB;

			");


			var a1 = new author();
			a1.name = "Bill";
			await db.InsertAsync(a1);

			var a2 = new author();
			a2.name = "Ted";
			await db.InsertAsync(a2);

			var p = new post();
			p.title = "post1";
			p.author = a1.id;
			await db.InsertAsync(p);

			p = new post();
			p.title = "post2";
			p.author = a1.id;
			await db.InsertAsync(p);

			p = new post();
			p.title = "post3";
			p.author = a2.id;
			await db.InsertAsync(p);

		}
开发者ID:bamboo82,项目名称:AsyncPoco,代码行数:48,代码来源:MultiPocoTests.cs

示例5: AddDeviceToRoomAsync

        public async Task AddDeviceToRoomAsync(string gatewayName, string deviceId, string roomId)
        {
            using (var database = new Database("ConnectionString"))
            {
                const string sql = @"
if (select count(*) from RoomDevice where Gateway = @0 and Id = @1) > 0
begin
  update RoomDevice set RoomId = @2 where Gateway = @0 and Id = @1
end
else
begin
  insert into RoomDevice (Gateway, Id, RoomId) values (@0, @1, @2)
end";

                await database.ExecuteAsync(sql, gatewayName, deviceId, roomId);
            }
        }
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:17,代码来源:RoomDeviceService.cs

示例6: 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


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