本文整理汇总了C#中Table.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Table.Create方法的具体用法?C# Table.Create怎么用?C# Table.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFixtureSetUp
protected override void TestFixtureSetUp()
{
base.TestFixtureSetUp();
_session = Session;
_session.CreateKeyspace(_uniqueKsName);
_session.ChangeKeyspace(_uniqueKsName);
// Create necessary tables
MappingConfiguration config1 = new MappingConfiguration();
config1.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(EntityWithTimeUuid),
() => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(EntityWithTimeUuid)));
_tableEntityWithTimeUuid = new Table<EntityWithTimeUuid>(_session, config1);
_tableEntityWithTimeUuid.Create();
MappingConfiguration config2 = new MappingConfiguration();
config2.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(EntityWithNullableTimeUuid),
() => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(EntityWithNullableTimeUuid)));
_tableEntityWithNullableTimeUuid = new Table<EntityWithNullableTimeUuid>(_session, config2);
_tableEntityWithNullableTimeUuid.Create();
_expectedTimeUuidObjectList = EntityWithTimeUuid.GetDefaultObjectList();
_expectedNullableTimeUuidObjectList = EntityWithNullableTimeUuid.GetDefaultObjectList();
_dateBefore = DateTimeOffset.Parse("2014-2-1");
_dateAfter = DateTimeOffset.Parse("2014-4-1");
}
示例2: TableCreate_Create
public void TableCreate_Create()
{
// Test
Table<AllDataTypesEntity> table = new Table<AllDataTypesEntity>(_session, new MappingConfiguration());
table.Create();
WriteReadValidate(table);
}
示例3: TestFixtureSetUp
protected override void TestFixtureSetUp()
{
base.TestFixtureSetUp();
_session = Session;
_session.CreateKeyspace(_uniqueKsName);
_session.ChangeKeyspace(_uniqueKsName);
// Create necessary tables
MappingConfiguration config1 = new MappingConfiguration();
config1.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof (EntityWithTimeUuid),
() => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof (EntityWithTimeUuid)));
_tableEntityWithTimeUuid = new Table<EntityWithTimeUuid>(_session, config1);
_tableEntityWithTimeUuid.Create();
MappingConfiguration config2 = new MappingConfiguration();
config2.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof (EntityWithNullableTimeUuid),
() => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof (EntityWithNullableTimeUuid)));
_tableEntityWithNullableTimeUuid = new Table<EntityWithNullableTimeUuid>(_session, config2);
_tableEntityWithNullableTimeUuid.Create();
_expectedTimeUuidObjectList = EntityWithTimeUuid.GetDefaultObjectList();
for (int i=0; i<_expectedTimeUuidObjectList.Count; i++)
{
_expectedTimeUuidObjectList[i].StringType = i.ToString();
}
}
示例4: TableCreate_Create_NameOverride
public void TableCreate_Create_NameOverride()
{
string uniqueTableName = TestUtils.GetUniqueTableName();
Table<AllDataTypesEntity> table = new Table<AllDataTypesEntity>(_session, new MappingConfiguration(), uniqueTableName);
Assert.AreEqual(uniqueTableName, table.Name);
table.Create();
Assert.IsTrue(TestUtils.TableExists(_session, _uniqueKsName, uniqueTableName, true));
WriteReadValidate(table);
}
示例5: TestFixtureSetUp
protected override void TestFixtureSetUp()
{
base.TestFixtureSetUp();
_session = Session;
_session.CreateKeyspace(_uniqueKsName);
_session.ChangeKeyspace(_uniqueKsName);
_movieTable = new Table<Movie>(_session, new MappingConfiguration());
_movieTable.Create();
}
示例6: CreateTable_PartitionKeyOmitted
public void CreateTable_PartitionKeyOmitted()
{
Map<ManyDataTypesPoco> mappingWithoutPk = new Map<ManyDataTypesPoco>();
var table = new Table<ManyDataTypesPoco>(_session, new MappingConfiguration().Define(mappingWithoutPk));
var e = Assert.Throws<InvalidOperationException>(() => table.Create());
string expectedErrMsg = "Cannot create CREATE statement for POCO of type " + typeof(ManyDataTypesPoco).Name +
" because it is missing PK columns id. Are you missing a property/field on the POCO or did you forget to specify the PK columns in the mapping?";
Assert.AreEqual(expectedErrMsg, e.Message);
}
示例7: TestFixtureSetUp
public void TestFixtureSetUp()
{
var testCluster = TestClusterManager.GetTestCluster(1, DefaultMaxClusterCreateRetries, true, false);
_cluster = Cluster.Builder().AddContactPoint(testCluster.InitialContactPoint).Build();
_session = _cluster.Connect();
_session.CreateKeyspace(_uniqueKsName);
_session.ChangeKeyspace(_uniqueKsName);
_movieTable = new Table<Movie>(_session, new MappingConfiguration());
_movieTable.Create();
}
示例8: CqlClientConfiguration_UseIndividualMappingClassType_StaticMappingClass
public void CqlClientConfiguration_UseIndividualMappingClassType_StaticMappingClass()
{
var config = new MappingConfiguration().Define(new ManyDataTypesPocoMappingCaseSensitive());
var table = new Table<ManyDataTypesPoco>(_session, config);
table.Create();
var mapper = new Mapper(_session, config);
ManyDataTypesPoco manyTypesInstance = ManyDataTypesPoco.GetRandomInstance();
mapper.Insert(manyTypesInstance);
string cqlSelect = string.Format("SELECT * from \"{0}\" where \"{1}\"='{2}'", table.Name, "StringType", manyTypesInstance.StringType);
ManyDataTypesPoco.KeepTryingSelectAndAssert(mapper, cqlSelect, new List<ManyDataTypesPoco>() { manyTypesInstance });
}
示例9: CreateTableBlind
public void CreateTableBlind()
{
PrepareForTableCreation("Blind");
Table Blind = new Table(PokerPalooza, "Blind");
Blind.Columns.Add(new Column(Blind, "ID", DataType.Int));
Blind.Columns["ID"].Identity = true;
Blind.Columns.Add(new Column(Blind, "BlindSetupId", DataType.Int));
Blind.Columns.Add(new Column(Blind, "Interval", DataType.Int));
Blind.Columns.Add(new Column(Blind, "BlindLevel", DataType.Int));
PokerPalooza.Tables.Add(Blind);
Blind.Create();
}
示例10: CqlClientConfiguration_UseIndividualMappingGeneric_StaticMappingClass_
public void CqlClientConfiguration_UseIndividualMappingGeneric_StaticMappingClass_()
{
var config = new MappingConfiguration().Define(new ManyDataTypesPocoMappingCaseSensitive());
var table = new Table<ManyDataTypesPoco>(_session, config);
Assert.AreNotEqual(table.Name, table.Name.ToLower()); // make sure the case sensitivity rule is being used
table.Create();
var mapper = new Mapper(_session, config);
var manyTypesInstance = ManyDataTypesPoco.GetRandomInstance();
mapper.Insert(manyTypesInstance);
var instancesQueried = mapper.Fetch<ManyDataTypesPoco>().ToList();
Assert.AreEqual(1, instancesQueried.Count);
manyTypesInstance.AssertEquals(instancesQueried[0]);
}
示例11: CreateTable_FluentMapping_Success
public void CreateTable_FluentMapping_Success()
{
var mappingConfig = new MappingConfiguration().Define(new ManyDataTypesPocoMappingCaseSensitive());
var table = new Table<ManyDataTypesPoco>(_session, mappingConfig);
table.Create();
var mapper = new Mapper(_session, mappingConfig);
ManyDataTypesPoco manyTypesInstance = ManyDataTypesPoco.GetRandomInstance();
mapper.Insert(manyTypesInstance);
string cqlSelect = string.Format("SELECT * from \"{0}\" where \"{1}\"='{2}'", table.Name, "StringType", manyTypesInstance.StringType);
List<ManyDataTypesPoco> instancesQueried = mapper.Fetch<ManyDataTypesPoco>(cqlSelect).ToList();
Assert.AreEqual(1, instancesQueried.Count);
instancesQueried[0].AssertEquals(manyTypesInstance);
}
示例12: Counter_LinqAttributes_AttemptInsert
public void Counter_LinqAttributes_AttemptInsert()
{
var table = new Table<PocoWithCounterAttribute>(_session, new MappingConfiguration());
table.Create();
PocoWithCounterAttribute pocoAndLinqAttributesPocos = new PocoWithCounterAttribute()
{
KeyPart1 = Guid.NewGuid(),
KeyPart2 = (decimal)123,
};
// Validate Error Message
var e = Assert.Throws<InvalidQueryException>(() => table.Insert(pocoAndLinqAttributesPocos).Execute());
string expectedErrMsg = "INSERT statement(s)? are not allowed on counter tables, use UPDATE instead";
StringAssert.IsMatch(expectedErrMsg, e.Message);
}
示例13: createrTable
public void createrTable()
{
Table table=new Table(ser.Databases[dbName],tName);
Column colID=new Column(table,"UID",new DataType(SqlDataType.Int));
Column colName = new Column(table, "UNAME", new DataType(SqlDataType.VarChar, 50));
Column colSex = new Column(table, "USEX", new DataType(SqlDataType.Bit));
Column colBrithday = new Column(table, "UBRITHDAY", new DataType(SqlDataType.DateTime));
Column colAddress = new Column(table, "UADDRESS", new DataType(SqlDataType.VarChar, 200));
table.Columns.Add(colID);
table.Columns.Add(colName);
table.Columns.Add(colSex);
table.Columns.Add(colBrithday);
table.Columns.Add(colAddress);
table.Create();
}
示例14: LinqAttributes_Counter
public void LinqAttributes_Counter()
{
//var mapping = new Map<PocoWithCounter>();
var mappingConfig = new MappingConfiguration();
mappingConfig.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(CounterEntityWithLinqAttributes),
() => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(CounterEntityWithLinqAttributes)));
var table = new Table<CounterEntityWithLinqAttributes>(_session, mappingConfig);
table.Create();
List<CounterEntityWithLinqAttributes> counterPocos = new List<CounterEntityWithLinqAttributes>();
for (int i = 0; i < 10; i++)
{
counterPocos.Add(
new CounterEntityWithLinqAttributes()
{
KeyPart1 = Guid.NewGuid(),
KeyPart2 = (decimal)123,
});
}
int counterIncrements = 100;
string updateStr = String.Format("UPDATE \"{0}\" SET \"{1}\"=\"{1}\" + 1 WHERE \"{2}\"=? and \"{3}\"=?", typeof(CounterEntityWithLinqAttributes).Name, "Counter", "KeyPart1", "KeyPart2");
var updateSession = _session.Prepare(updateStr);
foreach (CounterEntityWithLinqAttributes pocoWithCounter in counterPocos)
{
var boundStatement = updateSession.Bind(new object[] { pocoWithCounter.KeyPart1, pocoWithCounter.KeyPart2 });
for (int j = 0; j < counterIncrements; j++)
_session.Execute(boundStatement);
pocoWithCounter.Counter += counterIncrements;
}
List<CounterEntityWithLinqAttributes> countersQueried = table.Select(m => m).Execute().ToList();
foreach (CounterEntityWithLinqAttributes pocoWithCounterExpected in counterPocos)
{
bool counterFound = false;
foreach (CounterEntityWithLinqAttributes pocoWithCounterActual in countersQueried)
{
if (pocoWithCounterExpected.KeyPart1 == pocoWithCounterActual.KeyPart1)
{
Assert.AreEqual(pocoWithCounterExpected.KeyPart2, pocoWithCounterExpected.KeyPart2);
Assert.AreEqual(pocoWithCounterExpected.Counter, pocoWithCounterExpected.Counter);
counterFound = true;
}
}
Assert.IsTrue(counterFound, "Counter with first key part: " + pocoWithCounterExpected.KeyPart1 + " was not found!");
}
}
示例15: SetupSessionAndCluster
private ITestCluster SetupSessionAndCluster(int nodes, Dictionary<string, string> replication = null)
{
ITestCluster testCluster = TestClusterManager.GetTestCluster(nodes);
_session = testCluster.Session;
_ksName = TestUtils.GetUniqueKeyspaceName();
_session.CreateKeyspace(_ksName, replication);
TestUtils.WaitForSchemaAgreement(_session.Cluster);
_session.ChangeKeyspace(_ksName);
_table = new Table<ManyDataTypesEntity>(_session, new MappingConfiguration());
_table.Create();
_defaultPocoList = ManyDataTypesEntity.GetDefaultAllDataTypesList();
_preparedStatement = _session.Prepare(_preparedInsertStatementAsString);
foreach (var manyDataTypesEntity in _defaultPocoList)
_session.Execute(GetBoundInsertStatementBasedOnEntity(manyDataTypesEntity));
return testCluster;
}