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


C# DynamicParameters.Output方法代码示例

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


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

示例1: TestSupportForDynamicParametersOutputExpressions_Scalar

        public void TestSupportForDynamicParametersOutputExpressions_Scalar()
        {
            using (var connection = Program.GetOpenConnection())
            {
                var bob = new Person { Name = "bob", PersonId = 1, Address = new Address { PersonId = 2 } };

                var p = new DynamicParameters(bob);
                p.Output(bob, b => b.PersonId);
                p.Output(bob, b => b.Occupation);
                p.Output(bob, b => b.NumberOfLegs);
                p.Output(bob, b => b.Address.Name);
                p.Output(bob, b => b.Address.PersonId);

                var result = (int)connection.ExecuteScalarAsync(@"
            SET @Occupation = 'grillmaster'
            SET @PersonId = @PersonId + 1
            SET @NumberOfLegs = @NumberOfLegs - 1
            SET @AddressName = 'bobs burgers'
            SET @AddressPersonId = @PersonId
            select 42", p).Result;

                bob.Occupation.IsEqualTo("grillmaster");
                bob.PersonId.IsEqualTo(2);
                bob.NumberOfLegs.IsEqualTo(1);
                bob.Address.Name.IsEqualTo("bobs burgers");
                bob.Address.PersonId.IsEqualTo(2);
                result.IsEqualTo(42);
            }
        }
开发者ID:9527y,项目名称:dapper-dot-net,代码行数:29,代码来源:Tests.cs

示例2: TestSupportForDynamicParametersOutputExpressions_Query_NonBuffered

        public void TestSupportForDynamicParametersOutputExpressions_Query_NonBuffered()
        {
            using (var connection = Program.GetOpenConnection())
            {
                var bob = new Person { Name = "bob", PersonId = 1, Address = new Address { PersonId = 2 } };

                var p = new DynamicParameters(bob);
                p.Output(bob, b => b.PersonId);
                p.Output(bob, b => b.Occupation);
                p.Output(bob, b => b.NumberOfLegs);
                p.Output(bob, b => b.Address.Name);
                p.Output(bob, b => b.Address.PersonId);

                var result = connection.QueryAsync<int>(new CommandDefinition(@"
            SET @Occupation = 'grillmaster'
            SET @PersonId = @PersonId + 1
            SET @NumberOfLegs = @NumberOfLegs - 1
            SET @AddressName = 'bobs burgers'
            SET @AddressPersonId = @PersonId
            select 42", p, flags: CommandFlags.None)).Result.Single();

                bob.Occupation.IsEqualTo("grillmaster");
                bob.PersonId.IsEqualTo(2);
                bob.NumberOfLegs.IsEqualTo(1);
                bob.Address.Name.IsEqualTo("bobs burgers");
                bob.Address.PersonId.IsEqualTo(2);
                result.IsEqualTo(42);
            }
        }
开发者ID:9527y,项目名称:dapper-dot-net,代码行数:29,代码来源:Tests.cs

示例3: TestSupportForDynamicParametersOutputExpressions_Query_Default

        public async Task TestSupportForDynamicParametersOutputExpressions_Query_Default()
        {
            using (var connection = Program.GetOpenConnection())
            {
                var bob = new Person { Name = "bob", PersonId = 1, Address = new Address { PersonId = 2 } };

                var p = new DynamicParameters(bob);
                p.Output(bob, b => b.PersonId);
                p.Output(bob, b => b.Occupation);
                p.Output(bob, b => b.NumberOfLegs);
                p.Output(bob, b => b.Address.Name);
                p.Output(bob, b => b.Address.PersonId);

                var result = (await connection.QueryAsync<int>(@"
SET @Occupation = 'grillmaster' 
SET @PersonId = @PersonId + 1 
SET @NumberOfLegs = @NumberOfLegs - 1
SET @AddressName = 'bobs burgers'
SET @AddressPersonId = @PersonId
select 42", p)).Single();

                bob.Occupation.IsEqualTo("grillmaster");
                bob.PersonId.IsEqualTo(2);
                bob.NumberOfLegs.IsEqualTo(1);
                bob.Address.Name.IsEqualTo("bobs burgers");
                bob.Address.PersonId.IsEqualTo(2);
                result.IsEqualTo(42);
            }
        }
开发者ID:kuacci,项目名称:dapper-dot-net,代码行数:29,代码来源:Tests.Async.cs

示例4: TestSupportForDynamicParametersOutputExpressions_QueryMultiple

        public void TestSupportForDynamicParametersOutputExpressions_QueryMultiple()
        {
            using (var connection = Program.GetOpenConnection())
            {
                var bob = new Person { Name = "bob", PersonId = 1, Address = new Address { PersonId = 2 } };

                var p = new DynamicParameters(bob);
                p.Output(bob, b => b.PersonId);
                p.Output(bob, b => b.Occupation);
                p.Output(bob, b => b.NumberOfLegs);
                p.Output(bob, b => b.Address.Name);
                p.Output(bob, b => b.Address.PersonId);

                int x, y;
                using (var multi = connection.QueryMultipleAsync(@"
            SET @Occupation = 'grillmaster'
            SET @PersonId = @PersonId + 1
            SET @NumberOfLegs = @NumberOfLegs - 1
            SET @AddressName = 'bobs burgers'
            select 42
            select 17
            SET @AddressPersonId = @PersonId", p).Result)
                {
                    x = multi.ReadAsync<int>().Result.Single();
                    y = multi.ReadAsync<int>().Result.Single();
                }

                bob.Occupation.IsEqualTo("grillmaster");
                bob.PersonId.IsEqualTo(2);
                bob.NumberOfLegs.IsEqualTo(1);
                bob.Address.Name.IsEqualTo("bobs burgers");
                bob.Address.PersonId.IsEqualTo(2);
                x.IsEqualTo(42);
                y.IsEqualTo(17);
            }
        }
开发者ID:9527y,项目名称:dapper-dot-net,代码行数:36,代码来源:Tests.cs

示例5: TestSupportForDynamicParametersOutputExpressions

        public async Task TestSupportForDynamicParametersOutputExpressions()
        {
            using (var connection = Program.GetOpenConnection())
            {
                var bob = new Person { Name = "bob", PersonId = 1, Address = new Address { PersonId = 2 } };

                var p = new DynamicParameters(bob);
                p.Output(bob, b => b.PersonId);
                p.Output(bob, b => b.Occupation);
                p.Output(bob, b => b.NumberOfLegs);
                p.Output(bob, b => b.Address.Name);
                p.Output(bob, b => b.Address.PersonId);

                await connection.ExecuteAsync(@"
SET @Occupation = 'grillmaster' 
SET @PersonId = @PersonId + 1 
SET @NumberOfLegs = @NumberOfLegs - 1
SET @AddressName = 'bobs burgers'
SET @AddressPersonId = @PersonId", p);

                bob.Occupation.IsEqualTo("grillmaster");
                bob.PersonId.IsEqualTo(2);
                bob.NumberOfLegs.IsEqualTo(1);
                bob.Address.Name.IsEqualTo("bobs burgers");
                bob.Address.PersonId.IsEqualTo(2);
            }
        }
开发者ID:kuacci,项目名称:dapper-dot-net,代码行数:27,代码来源:Tests.Async.cs


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