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


C# DynamicRepository.Single方法代码示例

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


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

示例1: saving_dynamic_params

        void saving_dynamic_params()
        {
            before = () =>
            {
                seed = new Seed();

                seed.PurgeDb();

                seed.CreateTable("Blogs", new dynamic[]
                {
                    new { Id = "int", Identity = true, PrimaryKey = true },
                    new { Title = "nvarchar(255)" }
                }).ExecuteNonQuery();

                nameValueCollection.Add("Title", "Some Title");
            };

            it["persists saveable values to the database"] = () =>
            {
                var blogs = new DynamicRepository("Blogs");

                var blogId = blogs.Insert(asDynamic);

                var blog = blogs.Single(blogId);

                (blog.Title as string).should_be("Some Title");
            };
        }
开发者ID:pragmaticlogic,项目名称:Oak,代码行数:28,代码来源:describe_ParamsModelBinder.cs

示例2: mass_assignment

        void mass_assignment()
        {
            before = () =>
            {
                seed = new Seed();

                seed.PurgeDb();

                seed.CreateTable("Users", new dynamic[]
                {
                    new { Id = "int", Identity = true, PrimaryKey = true },
                    new { Name = "nvarchar(255)" },
                    new { IsAdmin = "bit", Default = false }
                }).ExecuteNonQuery();

                nameValueCollection.Add("Name", "John");

                nameValueCollection.Add("IsAdmin", "true");
            };

            it["allows the ability to exclude fields"] = () =>
            {
                var users = new DynamicRepository("Users");

                var userId = users.Insert(asDynamic.Exclude("IsAdmin"));

                var user = users.Single(userId);

                (user.Name as string).should_be("John");

                ((bool)user.IsAdmin).should_be(false);
            };

            it["allows the ability to select fields"] = () =>
            {
                var users = new DynamicRepository("Users");

                var userId = users.Insert(asDynamic.Select("Name"));

                var user = users.Single(userId);

                (user.Name as string).should_be("John");

                ((bool)user.IsAdmin).should_be(false);
            };
        }
开发者ID:pragmaticlogic,项目名称:Oak,代码行数:46,代码来源:describe_ParamsModelBinder.cs


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