本文整理汇总了C#中NHibernate.Mapping.SimpleValue类的典型用法代码示例。如果您正苦于以下问题:C# SimpleValue类的具体用法?C# SimpleValue怎么用?C# SimpleValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleValue类属于NHibernate.Mapping命名空间,在下文中一共展示了SimpleValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnmatchingColumns
public void UnmatchingColumns()
{
Table primaryTable = new Table("pktable");
primaryTable.PrimaryKey = new PrimaryKey();
SimpleValue sv = new SimpleValue();
sv.TypeName = NHibernateUtil.Int16.Name;
Column pkColumn = new Column("pk_column");
pkColumn.Value = sv;
primaryTable.PrimaryKey.AddColumn(pkColumn);
Table fkTable = new Table("fktable");
ForeignKey fk = new ForeignKey();
sv = new SimpleValue();
sv.TypeName = NHibernateUtil.Int16.Name;
Column fkColumn1 = new Column("col1");
fkColumn1.Value = sv;
sv = new SimpleValue();
sv.TypeName = NHibernateUtil.Int16.Name;
Column fkColumn2 = new Column("col2");
fkColumn2.Value = sv;
fk.AddColumn(fkColumn1);
fk.AddColumn(fkColumn2);
fk.Table = fkTable;
fk.ReferencedTable = primaryTable;
Assert.Throws<FKUnmatchingColumnsException>(() => fk.AlignColumns());
}
示例2: BindTimestamp
private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table)
{
if (timestampSchema == null)
return;
string propertyName = timestampSchema.name;
SimpleValue simpleValue = new SimpleValue(table);
BindColumns(timestampSchema, simpleValue, propertyName);
if (!simpleValue.IsTypeSpecified)
simpleValue.TypeName = NHibernateUtil.Timestamp.Name;
Mapping.Property property = new Mapping.Property(simpleValue);
BindProperty(timestampSchema, property);
// for version properties marked as being generated, make sure they are "always"
// generated; "insert" is invalid. This is dis-allowed by the schema, but just to make
// sure...
if (property.Generation == PropertyGeneration.Insert)
throw new MappingException("'generated' attribute cannot be 'insert' for versioning property");
simpleValue.NullValue = timestampSchema.unsavedvalue;
rootClass.Version = property;
rootClass.AddProperty(property);
}
示例3: CreateIdentifierProperty
private void CreateIdentifierProperty(HbmId idSchema, PersistentClass rootClass, SimpleValue id)
{
if (idSchema.name != null)
{
string access = idSchema.access ?? mappings.DefaultAccess;
id.SetTypeUsingReflection(rootClass.MappedClass.AssemblyQualifiedName, idSchema.name, access);
Mapping.Property property = new Mapping.Property(id);
property.Name = idSchema.name;
if (property.Value.Type == null)
throw new MappingException("could not determine a property type for: " + property.Name);
property.PropertyAccessorName = idSchema.access ?? mappings.DefaultAccess;
property.Cascade = mappings.DefaultCascade;
property.IsUpdateable = true;
property.IsInsertable = true;
property.IsOptimisticLocked = true;
property.Generation = PropertyGeneration.Never;
property.MetaAttributes = GetMetas(idSchema);
rootClass.IdentifierProperty = property;
LogMappedProperty(property);
}
}
示例4: BindId
public void BindId(HbmId idSchema, PersistentClass rootClass, Table table)
{
if (idSchema != null)
{
var id = new SimpleValue(table);
new TypeBinder(id, Mappings).Bind(idSchema.Type);
rootClass.Identifier = id;
Func<HbmColumn> defaultColumn = () => new HbmColumn
{
name = idSchema.name ?? RootClass.DefaultIdentifierColumnName,
length = idSchema.length
};
new ColumnsBinder(id, Mappings).Bind(idSchema.Columns, false, defaultColumn);
CreateIdentifierProperty(idSchema, rootClass, id);
VerifiyIdTypeIsValid(id.Type, rootClass.EntityName);
new IdGeneratorBinder(Mappings).BindGenerator(id, GetIdGenerator(idSchema));
id.Table.SetIdentifierValue(id);
BindUnsavedValue(idSchema, id);
}
}
示例5: BindSimpleValue
private void BindSimpleValue(HbmDiscriminator discriminatorSchema, SimpleValue discriminator)
{
if (discriminatorSchema.type != null)
discriminator.TypeName = discriminatorSchema.type;
if (discriminatorSchema.formula != null)
{
var f = new Formula {FormulaString = discriminatorSchema.formula};
discriminator.AddFormula(f);
}
else
{
new ColumnsBinder(discriminator, Mappings).Bind(discriminatorSchema.Columns, false,
() =>
new HbmColumn
{
name =
mappings.NamingStrategy.PropertyToColumnName(
RootClass.DefaultDiscriminatorColumnName),
length = discriminatorSchema.length,
notnull = discriminatorSchema.notnull,
notnullSpecified = true
});
}
}
示例6: BindGenerator
public void BindGenerator(SimpleValue id, HbmGenerator generatorMapping)
{
if (generatorMapping != null)
{
if ([email protected] == null)
throw new MappingException("no class given for generator");
// NH Differen behavior : specific feature NH-1817
TypeDef typeDef = mappings.GetTypeDef([email protected]);
if (typeDef != null)
{
id.IdentifierGeneratorStrategy = typeDef.TypeClass;
// parameters on the property mapping should override parameters in the typedef
var allParameters = new Dictionary<string, string>(typeDef.Parameters);
ArrayHelper.AddAll(allParameters, GetGeneratorProperties(generatorMapping, id.Table.Schema));
id.IdentifierGeneratorProperties = allParameters;
}
else
{
id.IdentifierGeneratorStrategy = [email protected];
id.IdentifierGeneratorProperties = GetGeneratorProperties(generatorMapping, id.Table.Schema);
}
}
}
示例7: CreateIdentifier
private static SimpleValue CreateIdentifier(HbmId idSchema, PersistentClass rootClass, Table table)
{
SimpleValue iv = new SimpleValue(table);
iv.TypeName = idSchema.type;
rootClass.Identifier = iv;
return iv;
}
示例8: BindColumn
protected virtual void BindColumn(SimpleValue model, ColumnMapping columnMapping)
{
Table table = model.Table;
var column = CreateColumn(model, columnMapping);
if (table != null)
table.AddColumn(column);
model.AddColumn(column);
}
示例9: YesNoSqlType
public void YesNoSqlType()
{
SimpleValue sv = new SimpleValue();
sv.TypeName = NHibernateUtil.YesNo.Name;
Column column = new Column();
column.Value = sv;
string type = column.GetSqlType(_dialect, null);
Assert.AreEqual("CHAR(1)", type);
}
示例10: TypeBinder
public TypeBinder(SimpleValue value, Mappings mappings)
: base(mappings)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
this.value = value;
}
示例11: BindFk
public static void BindFk(PersistentClass referencedEntity,
PersistentClass destinationEntity,
Ejb3JoinColumn[] columns,
SimpleValue value,
bool unique,
ExtendedMappings mappings)
{
throw new NotImplementedException();
}
示例12: MakeVersion
public static void MakeVersion(XmlNode node, SimpleValue model)
{
if (node != null && node.Attributes != null)
{
XmlAttribute attribute = node.Attributes["unsaved-value"];
model.NullValue = attribute == null ? null : attribute.Value;
}
else
model.NullValue = null;
}
示例13: AddColumns
private void AddColumns(HbmId idSchema, SimpleValue id)
{
if (idSchema.column1 != null)
AddColumnFromAttribute(idSchema, id);
else
AddColumnsFromList(idSchema, id);
if (id.ColumnSpan == 0)
AddDefaultColumn(idSchema, id);
}
示例14: StringSqlType
public void StringSqlType()
{
SimpleValue sv = new SimpleValue();
sv.TypeName = NHibernateUtil.String.Name;
Column column = new Column();
column.Value = sv;
Assert.AreEqual("NVARCHAR(255)", column.GetSqlType(_dialect, null));
column.Length = 100;
Assert.AreEqual("NVARCHAR(100)", column.GetSqlType(_dialect, null));
}
示例15: CheckDefaultUnsavedValue
private void CheckDefaultUnsavedValue( string versionTag )
{
string XML = GetXmlForTesting( versionTag );
XmlDocument document = LoadAndValidate( XML );
XmlNode node = document.GetElementsByTagName( versionTag )[0];
SimpleValue model = new SimpleValue();
Binder.MakeVersion( node, model );
Assert.IsNull( model.NullValue,
"default unsaved-value for tag {0} should be null, but is '{1}'",
versionTag, model.NullValue );
}