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


C# DataContext.CreateTableIfNotExists方法代码示例

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


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

示例1: CreateTablesIfTheyDoNotExist

        private static void CreateTablesIfTheyDoNotExist()
        {
            var ctx = new DataContext(DynamoDbClient, string.Empty);

            ctx.OnLog += ExternalLoggingRoutine.Log;

            ctx.CreateTableIfNotExists
                (
                    new CreateTableArgs<Genre>
                        (
                        1, 1,
                        g => g.Title,
                        null, null,
                        Genre.GetInitialEntities
                        // Do not implement this via an anonymous method! Because it's called within static constructor, the call will block indefinitely!
                        )
                );

            ctx.CreateTableIfNotExists
                (
                    new CreateTableArgs<Movie>
                        (
                        m => m.Genre,
                        m => m.Title,
                        m => m.Director,
                        m => m.Year,
                        m => m.Budget
                        )
                );

            ctx.CreateTableIfNotExists
                (
                    new CreateTableArgs<Review>
                        (
                        10, 10,
                        r => r.MovieId,
                        r => r.Reviewer
                        )
                );

            ctx.CreateTableIfNotExists
                (
                    new CreateTableArgs<Reviewers>
                        (
                        r => r.Login
                        )
                );
        }
开发者ID:LCHarold,项目名称:linq2dynamodb,代码行数:48,代码来源:ReviewsDataContext.cs

示例2: CreateTablesIfTheyDoNotExist

 private static void CreateTablesIfTheyDoNotExist()
 {
     var ctx = new DataContext(DynamoDbClient, string.Empty);
     ctx.CreateTableIfNotExists
     (
         new CreateTableArgs<Note>
         (
             // hash key
             "UserId", typeof(string), 
             // range key
             g => g.ID, 
             // secondary index
             (Expression<Func<Note, object>>)(g => g.TimeCreated)
         )
     );
 }
开发者ID:LCHarold,项目名称:linq2dynamodb,代码行数:16,代码来源:NotesDataContext.cs

示例3: DataContext

        public void DataContext()
        {
            var client = TestConfiguration.GetDynamoDbClient();
            var ctx = new DataContext(client);
            ctx.CreateTableIfNotExists(
                new CreateTableArgs<Book>(
                    1,
                    1,
                    r => r.Name,
                    r => r.PublishYear,
                    null,
                    null,
                    () =>
                        new[]
                        {
                            new Book
                            {
                                Name = "TestBook" + Guid.NewGuid(),
                                PublishYear = 2016,
                                Author = "foo",
                                NumPages = 25,
                                PopularityRating = default(Book.Popularity),
                                UserFeedbackRating = default(Book.Stars),
                                RentingHistory = default(List<string>),
                                FilmsBasedOnBook = default(IDictionary<string, TimeSpan>),
                                LastRentTime = default(DateTime),
                                Publisher = default(Book.PublisherDto),
                                ReviewsList = default(List<Book.ReviewDto>)
                            }
                        }));

            var table = ctx.GetTable<Book>();

            //TODO: figure out a way to directly prove that the tablename prefix is getting applied, rather than this indirect approach
            var result = table.FirstOrDefault();
            Assert.IsNotNull(result);
        }
开发者ID:LCHarold,项目名称:linq2dynamodb,代码行数:37,代码来源:DataContextTests.cs


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