public override void AddParameter(IDataShape model) { foreach (PropertyInfo property in model.GetProperties()) { this._command.Parameters.Add(this._dbDao.CreateParameter(String.Format("@{0}", property.Name), model[property.Name])); } }
public override void BuildDictionary(IDataShape model) { foreach (PropertyInfo property in model.GetProperties()) { this._list.Add(String.Format("[{0}] = @{0}", property.Name)); } }
public override void BuildDictionary(IDataShape model) { foreach (PropertyInfo property in model.GetProperties()) { this._dictionary.Add(String.Format("[{0}]", property.Name), String.Format("@{0}", property.Name)); } }
public override void MountQuery(IDataShape model) { string query = String.Format("UPDATE [{0}] SET {1} WHERE [Id] = @Id", model.GetType().Name, String.Join(", ", this._list.ToArray())); this._command = this._dbDao.GetSqlCommand(query); }
public Object Run(IDataShape model) { this.BuildDictionary(model); this.MountQuery(model); this.AddParameter(model); return this.Execute(); }
public override void MountQuery(IDataShape model) { string query = String.Format("DELETE FROM [{0}] WHERE {1}", model.GetType().Name, String.Join(", ", this._list.ToArray())); this._command = this._dbDao.GetSqlCommand(query); }
public Object Run(IDataShape model) { this.BuildDictionary(model); this.MountQuery(model); this.AddParameter(model); return(this.Execute()); }
public override void MountQuery(IDataShape model) { string query = String.Format("INSERT INTO [{0}] ( {1} ) VALUES ( {2} )", model.GetType().Name, String.Join(", ", this._dictionary.Keys), String.Join(", ", this._dictionary.Values)); this._command = this._dbDao.GetSqlCommand(query); }
public override void MountQuery(IDataShape model) { string query = String.Format("SELECT * FROM [{0}] {1} {2}", model.GetType().Name, this._list.ToArray().Length > 0 ? "WHERE" : "", String.Join(" AND ", this._list.ToArray())); this._command = this._dbDao.GetSqlCommand(query); }
public object GetData(IDataReader reader) { if (this.IsInitialized.Equals(false)) { this.InitializeMapper(reader); } IDataShape model = this.CreateInstance(this.Model.GetType()); foreach (int map in this.OrdinalMappings) { if (!reader.IsDBNull(map)) { model[reader.GetName(map)] = reader.GetValue(map); } } return(model); }
public override void AddParameter(IDataShape model) { this._command.Parameters.Add(this._dbDao.CreateParameter("@Id", model["Id"])); }
public abstract void MountQuery(IDataShape model);
public abstract void BuildDictionary(IDataShape model);
public override void BuildDictionary(IDataShape model) { this._list.Add("[Id] = @Id"); }
public abstract void AddParameter(IDataShape model);
public bool Equals(IDataShape other) { return (ReferenceEquals(this, other) || Id.Equals(other.Id)); }
public DataMapper(Type type) { this.Model = this.CreateInstance(type); }