Esempio n. 1
0
        private void Insert(DatabaseObject obj)
        {
            if (!obj.NewlyCreated)
            {
                throw new InvalidOperationException("Insert of object not newly created.");
            }

            obj.Validate();

            var columns   = string.Join(", ", obj.Fields.Select(f => f.ColumnName));
            var variables = string.Join(", ", obj.Fields.Select(f => f.VariableName));

            using (var command = Command("INSERT INTO {0} ({1}) VALUES ({2})", TableName(obj.GetType()), columns, variables))
            {
                foreach (var f in obj.Fields)
                {
                    f.AddValue(command);
                }

                command.ExecuteNonQuery();
            }

            obj.Updated();
        }
Esempio n. 2
0
 public abstract void AssignLoad(DatabaseObject obj);
Esempio n. 3
0
 public MultiLanguageStringField(DatabaseObject obj, string columnName)
     : base(obj, columnName, false)
 {
     _value = new MultiLanguageString();
 }
Esempio n. 4
0
 public StringListField(DatabaseObject obj, string columnName, AllowStringType allowType = AllowStringType.SimpleText)
     : base(obj, columnName, false)
 {
     AllowType = allowType;
     _value    = new List <string>();
 }
Esempio n. 5
0
 protected ValueField(DatabaseObject obj, string columnName, bool nullable)
     : base(obj, columnName, nullable)
 {
 }
Esempio n. 6
0
 public EnumNullField(DatabaseObject obj, string columnName, Func <T, Translator, string> translate)
     : base(obj, columnName, true)
 {
     _value     = null;
     _translate = translate;
 }
Esempio n. 7
0
 public GuidIdPrimaryKeyField(DatabaseObject obj, Guid id)
     : base(obj, "id", id)
 {
 }
Esempio n. 8
0
 public EnumField(DatabaseObject obj, string columnName, T defaultValue, Func <T, Translator, string> translate)
     : base(obj, columnName, false)
 {
     _value     = defaultValue;
     _translate = translate;
 }
Esempio n. 9
0
 protected Field(DatabaseObject obj, string columnName, bool nullable)
 {
     ColumnName = columnName;
     Nullable   = nullable;
     obj.Fields.Add(this);
 }
Esempio n. 10
0
 public ReadOnlyField(DatabaseObject obj, string columnName, T defaultValue)
     : base(obj, columnName, false)
 {
     _value = defaultValue;
 }
Esempio n. 11
0
 public FieldClass(DatabaseObject obj, string columnName, bool nullable)
     : base(obj, columnName, nullable)
 {
     _value = null;
 }
Esempio n. 12
0
 public FieldNull(DatabaseObject obj, string columnName)
     : base(obj, columnName, true)
 {
     _value = null;
 }
Esempio n. 13
0
 public ProtoField(DatabaseObject obj, string columnName, bool nullable)
     : base(obj, columnName, nullable)
 {
 }