public override void Generate() { #line 37 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.EntityTypeColumns.cst" /* * TODO: Actually, all this should die and become a bunch of polymorphic calls. */ foreach (var p in properties) { // TODO: implement IsNullable everywhere if (p is CompoundObjectProperty) { ApplyEntityTypeColumnDefs( ((CompoundObjectProperty)p).CompoundObjectDefinition.Properties.Cast <Property>().OrderBy(prop => prop.Name), Construct.NestedColumnName(p, prefix), schemaProvider); } else if (p is ObjectReferenceProperty) { throw new ArgumentException("properties", String.Format("contains ObjectReferenceProperty {0}, but this template cannot work with that", p)); } else { string propertyName = Construct.NestedColumnName(p, prefix); string sqlTypeName = schemaProvider.DbTypeToNative(DbTypeMapper.GetDbTypeForProperty(p.GetType())); string maxLengthAttr = String.Empty; if (p is StringProperty) { int maxLength = ((StringProperty)p).GetMaxLength(); if (maxLength != int.MaxValue) { // must have one space at the end maxLengthAttr = String.Format("MaxLength=\"{0}\" ", maxLength); } } string precScaleAttr = String.Empty; if (p is DecimalProperty) { DecimalProperty dp = (DecimalProperty)p; // must have one space at the end precScaleAttr = String.Format("Precision=\"{0}\" Scale=\"{1}\" ", dp.Precision, dp.Scale); } string nullableAttr = String.Empty; if (p.IsValueTypePropertySingle()) { // must have one space at the end nullableAttr = String.Format("Nullable=\"{0}\" ", ((Property)p).IsNullable().ToString().ToLowerInvariant()); } #line 87 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.EntityTypeColumns.cst" this.WriteObjects(" <Property Name=\"", propertyName, "\" Type=\"", sqlTypeName, "\" ", maxLengthAttr, "", precScaleAttr, "", nullableAttr, "/>\r\n"); #line 89 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.EntityTypeColumns.cst" } } }
public void Initialize_DecimalProperty() { IBusinessObjectNumericProperty property = new DecimalProperty( GetPropertyParameters(GetPropertyInfo(typeof(ClassWithAllDataTypes), "Decimal"), _businessObjectProvider)); Assert.That(property.Type, Is.SameAs(typeof(Decimal))); Assert.That(property.AllowNegative, Is.True); }
public DecimalPropertyValueModel(INotifyingObject obj, DecimalProperty prop) : base(obj, prop) { dProp = prop; }
/// <summary> /// returns a <Property/> element describing the property /// without regards for the IsList flag. /// </summary> /// therefore it can be used both when defining a type (IsList == /// false) and when defining the CollectionEntry (IsList == true) internal static string PlainPropertyDefinitionFromValueType(ValueTypeProperty prop, string name, string implementationSuffix) { string type = prop.GetElementTypeString(); string maxlength = String.Empty; string precScaleAttr = String.Empty; string concurrency = String.Empty; // strip nullable "?" if (prop.IsNullable() && type.EndsWith("?")) { type = type.Substring(0, type.Length - 1); } switch (type) { case "bool": type = "Boolean"; break; case "decimal": type = "Decimal"; break; case "double": type = "Double"; break; case "int": type = "Int32"; break; case "string": type = "String"; break; } if (prop is EnumerationProperty) { type = "Int32"; name += implementationSuffix; } if (prop is StringProperty) { maxlength = String.Format("MaxLength=\"{0}\" ", ((StringProperty)prop).GetMaxLength()); } if (prop is DecimalProperty) { DecimalProperty dp = (DecimalProperty)prop; // must have one space at the end precScaleAttr = String.Format("Precision=\"{0}\" Scale=\"{1}\" ", dp.Precision, dp.Scale); } if (prop.ObjectClass is ObjectClass && ((ObjectClass)prop.ObjectClass).ImplementsIChangedBy() && prop.Name == "ChangedOn") { concurrency = "ConcurrencyMode=\"Fixed\""; } return(String.Format("<Property Name=\"{0}\" Type=\"{1}\" Nullable=\"{2}\" {3}{4} {5}/>", name, type, prop.IsNullable() ? "true" : "false", maxlength, precScaleAttr, concurrency)); }
public static void GetPropertyTypeString(DecimalProperty obj, MethodReturnEventArgs<string> e) { GetElementTypeString(obj, e); PropertyActions.DecorateParameterType(obj, e, true, obj.IsList, obj.HasPersistentOrder); }
public static void GetPropertyType(DecimalProperty obj, MethodReturnEventArgs<Type> e) { e.Result = typeof(decimal); PropertyActions.DecorateParameterType(obj, e, true, obj.IsList, obj.HasPersistentOrder); }
public static void GetElementTypeString(DecimalProperty obj, MethodReturnEventArgs<string> e) { e.Result = "decimal"; PropertyActions.DecorateElementType(obj, e, true); }
public static void GetPropertyTypeString(DecimalProperty obj, MethodReturnEventArgs <string> e) { GetElementTypeString(obj, e); PropertyActions.DecorateParameterType(obj, e, true, obj.IsList, obj.HasPersistentOrder); }
public static void GetElementTypeString(DecimalProperty obj, MethodReturnEventArgs <string> e) { e.Result = "decimal"; PropertyActions.DecorateElementType(obj, e, true); }
public static void GetPropertyType(DecimalProperty obj, MethodReturnEventArgs <Type> e) { e.Result = typeof(decimal); PropertyActions.DecorateParameterType(obj, e, true, obj.IsList, obj.HasPersistentOrder); }