本文整理汇总了C#中ClassMapping类的典型用法代码示例。如果您正苦于以下问题:C# ClassMapping类的具体用法?C# ClassMapping怎么用?C# ClassMapping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassMapping类属于命名空间,在下文中一共展示了ClassMapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCheckStoreRoomMissing
public void TestCheckStoreRoomMissing()
{
OleDbOracleDaLayer ddl =
new OleDbOracleDaLayer(
(OleDbDescriptor)
ConnectionDescriptor.LoadFromConfig(
new Config("..\\..\\Tests\\OracleDao.config", "OracleDaoConfig"), "DAO"));
// Make sure the store room to test does not exist
var colDef = new ClassMapColDefinition("Id", "Id", "INTEGER");
var cm = new ClassMapping("test", "UNITTEST.StoreroomDoesNotExist", new List<ClassMapColDefinition>{colDef}, false);
ddl.DeleteStoreRoom(cm);
try
{
// Hasn't been added yet, should not exist
Assert.IsTrue(
ddl.StoreRoomMissing(cm), "Oracle storeroom should not exist");
ddl.CreateStoreRoom(cm);
// Correct name, should exist
Assert.IsFalse(
ddl.StoreRoomMissing(cm), "Oracle Storeroom should exist");
}
finally
{
// Delete the storeromm, no matter what
ddl.DeleteStoreRoom(cm);
}
// Storeroom should be gone
Assert.IsTrue(
ddl.StoreRoomMissing(cm), "Oracle storeroom should not exist");
}
示例2: CreateSubclass
private ISubclassMapping CreateSubclass(ClassMapping mapping)
{
if (mapping.Discriminator == null)
return new JoinedSubclassMapping();
return new SubclassMapping();
}
示例3: StoreRoomMissing
/// <summary>
/// Returns true if you need to call "CreateStoreRoom" before storing any
/// data. This method is "Missing" not "Exists" because implementations that
/// do not use a store room can return "false" from this method without
/// breaking either a user's app or the spirit of the method.
///
/// Store room typically corresponds to "table".
/// Firebird doesn't appear to support the SQL standard information_schema.
/// </summary>
/// <returns>Returns true if you need to call "CreateStoreRoom"
/// before storing any data.</returns>
public override bool StoreRoomMissing(ClassMapping mapping)
{
int count = SqlConnectionUtilities.XSafeIntQuery(_connDesc,
"select count(*) from rdb$relations where rdb$relation_name = '" +
mapping.Table.ToUpper() + "'", null);
return count == 0;
}
示例4: GetStream
public Stream GetStream(ClassMapping clazz,string directory,out string fileName)
{
directoryForOutput = directory;
if (!string.IsNullOrEmpty(directoryForOutput))
{
if (!Directory.Exists(directoryForOutput))
Directory.CreateDirectory(directoryForOutput);
}
try
{
fileName = GetFileName(clazz);
}
catch
{
fileName = clazz.GeneratedName + ".cs";
log.Error("Error processing template for file name. " + fileName + " used.");
}
string toSave = Path.Combine(directoryForOutput, fileName);
FileStream output = new FileStream(toSave, FileMode.Create, FileAccess.ReadWrite);
log.Debug("Flushing output on file:" + output.Name);
fileName = toSave;
return output;
}
示例5: MemoryDataReader
/// <summary>
/// Create the data reader.
/// </summary>
/// <param name="layer">Layer creating it.</param>
/// <param name="mapping">Mapping for the class stored in the data store.</param>
/// <param name="criteria">Criteria for which instances you want.</param>
/// <param name="objects">Iterator over the list of objects.</param>
public MemoryDataReader(UnqueryableDaLayer layer, ClassMapping mapping, DaoCriteria criteria,
IEnumerator<MemoryObject> objects)
: base(layer, mapping, criteria, GetConfig(mapping))
{
_objects = objects;
PreProcessSorts();
}
示例6: ShouldMapByteArrayAsBinaryBlob
public void ShouldMapByteArrayAsBinaryBlob()
{
var mapping = new ClassMapping { Type = typeof(Target) };
mapper.Map(mapping, typeof(Target).GetProperty("Version"));
mapping.Version.Type.ShouldEqual(new TypeReference("BinaryBlob"));
}
示例7: ShouldMapByteArrayAsNotNull
public void ShouldMapByteArrayAsNotNull()
{
var mapping = new ClassMapping { Type = typeof(Target) };
mapper.Map(mapping, typeof(Target).GetProperty("Version").ToMember());
SpecificationExtensions.ShouldBeTrue(mapping.Version.Columns.All(x => x.NotNull == true));
}
示例8: ShouldMapInheritedByteArray
public void ShouldMapInheritedByteArray()
{
var mapping = new ClassMapping { Type = typeof(SubTarget) };
mapper.Map(mapping, typeof(SubTarget).GetProperty("Version"));
Assert.That(mapping.Version, Is.Not.Null);
}
示例9: ShouldMapByteArrayAsTimestampSqlType
public void ShouldMapByteArrayAsTimestampSqlType()
{
var mapping = new ClassMapping { Type = typeof(Target) };
mapper.Map(mapping, typeof(Target).GetProperty("Version"));
mapping.Version.Columns.All(x => x.SqlType == "timestamp").ShouldBeTrue();
}
示例10: ClassInspector
public ClassInspector(ClassMapping mapping)
{
this.mapping = mapping;
propertyMappings.Map(x => x.LazyLoad, x => x.Lazy);
propertyMappings.Map(x => x.ReadOnly, x => x.Mutable);
propertyMappings.Map(x => x.EntityType, x => x.Type);
}
示例11: ShouldSetContainingEntityType
public void ShouldSetContainingEntityType()
{
var mapping = new ClassMapping { Type = typeof(Target) };
mapper.Map(mapping, typeof(Target).GetProperty("Version").ToMember());
mapping.Version.ContainingEntityType.ShouldEqual(typeof(Target));
}
示例12: ShouldMapByteArrayAsNotNull
public void ShouldMapByteArrayAsNotNull()
{
var mapping = new ClassMapping { Type = typeof(Target) };
mapper.Map(mapping, typeof(Target).GetProperty("Version"));
mapping.Version.Columns.All(x => x.NotNull == true).ShouldBeTrue();
}
示例13: ShouldMapByteArrayWithUnsavedValueOfNull
public void ShouldMapByteArrayWithUnsavedValueOfNull()
{
var mapping = new ClassMapping { Type = typeof(Target) };
mapper.Map(mapping, typeof(Target).GetProperty("Version"));
mapping.Version.UnsavedValue.ShouldEqual(null);
}
示例14: ShouldWriteBag
public void ShouldWriteBag()
{
var mapping = new ClassMapping();
mapping.AddCollection(new BagMapping());
writer.VerifyXml(mapping)
.Element("bag").Exists();
}
示例15: ShouldWriteAny
public void ShouldWriteAny()
{
var mapping = new ClassMapping();
mapping.AddAny(new AnyMapping());
writer.VerifyXml(mapping)
.Element("any").Exists();
}