static void EntityType_BeforeDel(Xy.Data.Procedure procedure, Xy.Data.DataBase DB) { short inID = Convert.ToInt16(procedure.GetItem("ID")); EntityType _type = GetInstance(inID); System.Data.DataTable _childTypies = GetChildType(inID); foreach (System.Data.DataRow _childTypeRow in _childTypies.Rows) { EntityType _childType = new EntityType(); _childType.Fill(_childTypeRow); Del(_childType.ID); } StringBuilder _dropTableProcedure = new StringBuilder(); foreach (System.Data.DataRow _multiAttrsRow in EntityAttribute.GetByTypeID(inID).Rows) { EntityAttribute _attr = new EntityAttribute(); _attr.Fill(_multiAttrsRow); if (_attr.IsMultiple) { _dropTableProcedure.AppendLine(string.Format(_commandPartern_Del, "Entity_" + _type.Key + "_" + _attr.Key)); } } _dropTableProcedure.AppendLine(string.Format(_commandPartern_Del, "Entity_" + _type.Key)); Xy.Data.Procedure _deleteRelativeTable = new Xy.Data.Procedure("DeleteRelativeTable", _dropTableProcedure.ToString()); Xy.Data.Procedure _deleteRelativeEntityBase = new Xy.Data.Procedure("DeleteRelativeEntityBase", "Delete from [EntityBase] where [TypeID] = @ID", new Xy.Data.ProcedureParameter[] { new Xy.Data.ProcedureParameter("ID", System.Data.DbType.Int64) }); _deleteRelativeEntityBase.SetItem("ID", inID); _deleteRelativeTable.InvokeProcedure(DB); _deleteRelativeEntityBase.InvokeProcedure(DB); }
public static EntityAttribute GetInstance(long inID, Xy.Data.DataBase DB = null) { System.Data.DataTable result = Get(inID, DB); if (result.Rows.Count > 0) { EntityAttribute temp = new EntityAttribute(); temp.Fill(result.Rows[0]); return temp; } return null; }
internal EntityTypeCacheItem(short TypeID, Xy.Data.DataBase DB = null) { _hasMuli = false; _type = EntityType.GetInstance(TypeID); System.Data.DataTable _attrsTable = EntityAttribute.GetByTypeID(TypeID, DB); _attrs = new EntityAttribute[_attrsTable.Rows.Count + 4]; _attrKeys = new string[_attrsTable.Rows.Count + 4]; _attrNames = new string[_attrsTable.Rows.Count + 4]; List<string> _tempRelatedTables = new List<string>(); _tempRelatedTables.Add("EntityBase"); for (int i = 0; i < 4; i++) { EntityAttribute _item = null; switch (i) { case 0: _item = new EntityAttribute() { ID = -1, TypeID = -1, Name = "ID", Key = "ID", Type = "System.Data.DbType.Int64|", Default = string.Empty, IsMultiple = false, IsNull = false, Split = string.Empty, Description = "Defaut attirbute", Display = -1 }; break; case 1: _item = new EntityAttribute() { ID = -1, TypeID = -1, Name = "TypeID", Key = "TypeID", Type = "System.Data.DbType.Int16|", Default = string.Empty, IsMultiple = false, IsNull = false, Split = string.Empty, Description = "Defaut attirbute", Display = -1 }; break; case 2: _item = new EntityAttribute() { ID = -1, TypeID = -1, Name = "IsActive", Key = "IsActive", Type = "System.Data.DbType.Boolean|", Default = string.Empty, IsMultiple = false, IsNull = false, Split = string.Empty, Description = "Defaut attirbute", Display = -1 }; break; case 3: _item = new EntityAttribute() { ID = -1, TypeID = -1, Name = "UpdateTime", Key = "UpdateTime", Type = "System.Data.DbType.DateTime|", Default = string.Empty, IsMultiple = false, IsNull = false, Split = string.Empty, Description = "Defaut attirbute", Display = -1 }; break; } _attrs[i] = _item; _attrKeys[i] = _item.Key; _attrNames[i] = _item.Name; _attrDict.Add(_item.Key, i); } for (int i = 0; i < _attrsTable.Rows.Count; i++) { EntityAttribute _item = new EntityAttribute(); _item.Fill(_attrsTable.Rows[i]); //descrease make more comfortable and read-able sense if (_item.IsMultiple) _hasMuli = true; if (!_tempRelatedTables.Contains(_item.Table)) _tempRelatedTables.Add(_item.Table); _attrs[i + 4] = _item; _attrKeys[i + 4] = _item.Key; _attrNames[i + 4] = _item.Name; _attrDict.Add(_item.Key, i + 4); } _relatedTables = _tempRelatedTables.ToArray(); }