DataStax C# 驱动程序:如何创建 table 并设置 IEnumerable 的映射?
DataStax C# Driver: how to create table with mapping of IEnumerable to set?
我想使用 Table.CreateIfNotExists() 动态创建我的模式,但我不知道如何让它为 IEnumerable 创建 "set" 列类型而不是 "list".
如果不使用 CQL 语句创建 table 这可能吗?
For<ClassWithSet>()
.TableName("withset")
.PartitionKey(u => u.Id)
.Column(u => u.SomeStrings, cm => cm.WithName("somestrings").WithDbType<IEnumerable<string>>());
var table = new Table<ClassWithSet>(session);
table.CreateIfNotExists();
您应该使用 SortedSet<T>
作为数据库类型:
For<ClassWithSet>()
.TableName("withset")
.PartitionKey(u => u.Id)
.Column(u => u.SomeStrings,
cm => cm.WithName("somestrings").WithDbType<SortedSet<string>>());
var table = new Table<ClassWithSet>(session);
table.CreateIfNotExists();
我想使用 Table.CreateIfNotExists() 动态创建我的模式,但我不知道如何让它为 IEnumerable 创建 "set" 列类型而不是 "list".
如果不使用 CQL 语句创建 table 这可能吗?
For<ClassWithSet>()
.TableName("withset")
.PartitionKey(u => u.Id)
.Column(u => u.SomeStrings, cm => cm.WithName("somestrings").WithDbType<IEnumerable<string>>());
var table = new Table<ClassWithSet>(session);
table.CreateIfNotExists();
您应该使用 SortedSet<T>
作为数据库类型:
For<ClassWithSet>()
.TableName("withset")
.PartitionKey(u => u.Id)
.Column(u => u.SomeStrings,
cm => cm.WithName("somestrings").WithDbType<SortedSet<string>>());
var table = new Table<ClassWithSet>(session);
table.CreateIfNotExists();