예제 #1
0
        static void WriteValueProperty(ColumnModel column, IndentedTextWriter writer)
        {
            writer.WriteLine(@"///<summary>" + column.Description.EscapeXml() + @"</summary>");
            writer.WriteGeneratedCodeAttribute();
            writer.WriteLine(column.PropertyVisibility.ToString().ToLowerInvariant() + " " + column.ActualType + " " + column.PropertyName + " {");
            writer.Indent++;
            writer.WriteLine("get { return base.Field<" + column.ActualType + ">(" + column.ColumnPropertyName + "); }");

            if (string.IsNullOrEmpty(column.Expression))
                writer.WriteLine("set { base[" + column.ColumnPropertyName + "] = value; }");
            writer.Indent--;
            writer.WriteLine("}");
        }
예제 #2
0
 static void WriteColumnCreation(ColumnModel column, IndentedTextWriter writer)
 {
     if (column == column.Owner.PrimaryKey)
         writer.Write("Schema.PrimaryKey = ");
     if (!String.IsNullOrEmpty(column.Expression)) {
         writer.WriteLine(column.ColumnPropertyName
             + " = Schema.Columns.AddCalculatedColumn<" + column.Owner.RowClassName + ", " + column.ActualType + ">(" + column.Name.Quote()
             + ", row => " + column.Expression + ");");
     } else if (column.ForeignSchema != null) {
         writer.WriteLine(column.ColumnPropertyName
             + " = Schema.Columns.AddForeignKey(" + column.Name.Quote() + ", " + column.ForeignSchema.RowClassName + ".Schema, " + column.ForeignRelationName.Quote() + ");");
     } else {
         writer.WriteLine(column.ColumnPropertyName
             + " = Schema.Columns.AddValueColumn(" + column.Name.Quote() + ", typeof(" + column.DataType.Name + "), " + column.DefaultValueCode + ");");
     }
     if (typeof(ValueColumn).IsAssignableFrom(column.ColumnType)) {
         if (column.IsUnique)
             writer.WriteLine(column.ColumnPropertyName + ".Unique = true;");
         writer.WriteLine(column.ColumnPropertyName + ".AllowNulls = " + column.AllowNulls.ToString().ToLowerInvariant() + ";");
     }
 }
예제 #3
0
 static void WriteColumnPartials(ColumnModel column, IndentedTextWriter writer)
 {
     writer.WriteLine("partial void Validate" + column.PropertyName + "(" + column.ActualType + " newValue, Action<string> error);");
     writer.WriteLine("partial void On" + column.PropertyName + "Changed(" + column.NullableType + " oldValue, " + column.NullableType + " newValue);");
 }
예제 #4
0
 static void WriteColumnPartials(ColumnModel column, IndentedTextWriter writer)
 {
     writer.WriteLine("partial void Validate" + column.PropertyName + "(" + column.ActualType + " newValue, Action<string> error);");
     writer.WriteLine("partial void On" + column.PropertyName + "Changed(" + column.NullableType + " oldValue, " + column.NullableType + " newValue);");
 }