public void AddEmployeeNoAliasField() { DBSchemaProvider provider = db.GetSchemaProvider(); DBSchemaTable table = provider.GetTable("sys_User"); var fld = table.Columns.Where(x => x.Name.ToLower() == "oldemployeeno").FirstOrDefault(); if (fld == null) { string tblschema = "ALTER TABLE sys_User ADD oldemployeeno varchar(255) NULL"; try { int r = db.ExecuteNonQuery(tblschema); } catch (System.Exception ex) { // throw new Exception.TableSchemaException(this.Table, fields, Exception.OperaitonType.addkey, ex.Message); } } // DBSchemaItemRef table = tables.Where(x => x.Name.ToLower() == ).FirstOrDefault(); }
public static bool CheckFieldExist(string tbName, string fieldName, string conn) { DataBase db = new DataBase(); db.InitDbs(conn); DBSchemaTable tables; DBSchemaProvider provider = db.Database.GetSchemaProvider(); tables = provider.GetTable(tbName); var fd = tables.Columns.Where(x => x.Name.ToLower() == fieldName.ToLower()).FirstOrDefault(); if (fd == null) { return(false); } else { return(true); } }
/// <summary> /// /// </summary> /// <param name="tbName"></param> /// <returns></returns> public DBSchemaTable GetTable(string tbName) { DBSchemaProvider provider = db.GetSchemaProvider(); return(provider.GetTable(tbName)); }