本文整理汇总了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
)
);
}
示例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)
)
);
}
示例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);
}