예제 #1
0
 internal void GetSqlFieldInfo(string tableName)
 {
     SqlCommand selectCommand = new SqlCommand("exec sp_columns @table_name='" + tableName + "'", this.InfoRoot.SqlConn);
     DataSet dataSet = new DataSet();
     new SqlDataAdapter(selectCommand).Fill(dataSet, "Fields");
     selectCommand = new SqlCommand("exec sp_pkeys @table_name='" + tableName + "'", this.InfoRoot.SqlConn);
     new SqlDataAdapter(selectCommand).Fill(dataSet, "PKFields");
     selectCommand = new SqlCommand("select name from syscolumns where id = object_id('[" + tableName + "]') and iscomputed <> 0", this.InfoRoot.SqlConn);
     new SqlDataAdapter(selectCommand).Fill(dataSet, "CalcFields");
     DataColumn column = new DataColumn("CALCULATED", typeof(bool));
     dataSet.Tables["Fields"].Columns.Add(column);
     column = new DataColumn("PKEY", typeof(bool));
     dataSet.Tables["Fields"].Columns.Add(column);
     column = new DataColumn("AUTO", typeof(bool));
     dataSet.Tables["Fields"].Columns.Add(column);
     column = new DataColumn("PKPOSITION", typeof(short));
     dataSet.Tables["Fields"].Columns.Add(column);
     foreach (DataRow row in dataSet.Tables["Fields"].Rows)
     {
       row["AUTO"] = false;
       string str = (string)row["TYPE_NAME"];
       if (str.IndexOf("identity") > 0)
       {
     row["AUTO"] = true;
     row["TYPE_NAME"] = str.Replace("identity", "").Trim();
       }
       row["CALCULATED"] = false;
       foreach (DataRow row2 in dataSet.Tables["CalcFields"].Rows)
       {
     if (((string)row["COLUMN_NAME"]) == ((string)row2[0]))
     {
       row["CALCULATED"] = true;
     }
       }
       row["PKEY"] = false;
       row["PKPOSITION"] = -1;
       foreach (DataRow row3 in dataSet.Tables["PKFields"].Rows)
       {
     if (((string)row["COLUMN_NAME"]) == ((string)row3["COLUMN_NAME"]))
     {
       row["PKEY"] = true;
       row["PKPOSITION"] = row3["KEY_SEQ"];
     }
       }
     }
     this.m_AllFields = new SqlFieldInfoArray();
     this.m_InsertParamFields = new SqlFieldInfoArray();
     this.m_UpdateParamFields = new SqlFieldInfoArray();
     this.m_UpdateSetFields = new SqlFieldInfoArray();
     this.m_PKFields = new SqlFieldInfoArray();
     this.m_ConstructorFields = new SqlFieldInfoArray();
     foreach (DataRow row4 in dataSet.Tables["Fields"].Rows)
     {
       SqlFieldInfo sqlFieldInfo = new SqlFieldInfo(this, row4);
       this.m_AllFields.Add(sqlFieldInfo);
       if (sqlFieldInfo.IsPKField)
       {
     this.m_PKFields.Add(sqlFieldInfo);
       }
       if (!sqlFieldInfo.IsCalculated && !sqlFieldInfo.IsAutoCalculated)
       {
     this.m_InsertParamFields.Add(sqlFieldInfo);
       }
       if (!sqlFieldInfo.IsCalculated)
       {
     this.m_UpdateParamFields.Add(sqlFieldInfo);
       }
       if ((!sqlFieldInfo.IsPKField && !sqlFieldInfo.IsCalculated) && !sqlFieldInfo.IsAutoCalculated)
       {
     this.m_UpdateSetFields.Add(sqlFieldInfo);
       }
       if (sqlFieldInfo.IsPKField && !sqlFieldInfo.IsAutoCalculated)
       {
     this.m_ConstructorFields.Add(sqlFieldInfo);
       }
     }
 }
예제 #2
0
 public void Reload()
 {
     this.m_AllFields = null;
     this.m_PKFields = null;
     this.m_InsertParamFields = null;
     this.m_UpdateParamFields = null;
     this.m_UpdateSetFields = null;
     this.m_ConstructorFields = null;
 }