/// <summary> /// Получает информацию о сущностях из базы данных /// </summary> /// <returns></returns> public EntityData[] GetEntities() { Dictionary<string, EntityData> entities = new Dictionary<string, EntityData>(); foreach (DataRow dr in ds.Tables[0].Rows) { string className = dr["TABLE_NAME"].ToString(); EntityData edata =new EntityData(conn.Database, className); edata.DatabaseTableName = dr["TABLE_NAME"].ToString(); entities.Add(className, edata); } foreach (DataRow dr in ds.Tables[1].Rows) { EntityType t = new EntityType(); t.Name = dr["COLUMN_NAME"].ToString(); t.TypeName = DalTypeConverter.ToCLR(dr["DATA_TYPE"].ToString()); t.SqlTypeName = DalTypeConverter.ToSql(dr["DATA_TYPE"].ToString()); t.IsKey = (t.Name.ToUpper() == "ID") ? true : false; entities[dr["TABLE_NAME"].ToString()].Fields.Add(t); } foreach (DataRow dr in ds.Tables[2].Rows) { //stored procedures EntityData spEntity = new EntityData(dr["dataBase"].ToString(), dr["procedure"].ToString()); spEntity.IsStoredProcedure = true; entities.Add(spEntity.ClassName, spEntity); } foreach (DataRow dr in ds.Tables[3].Rows) { //stored procedures EntityType parameter = new EntityType(); parameter.Name = dr["parameterName"].ToString().Replace("@", ""); parameter.TypeName = DalTypeConverter.ToCLR(dr["parameterType"].ToString()); entities[dr["procedure"].ToString()].Fields.Add(parameter); } EntityData[] result = new EntityData[entities.Count]; entities.Values.CopyTo(result, 0); return result; }
public void Add(EntityType item) { items.Add(item); }