Пример #1
0
        public DataTable Query(List <string> columnList, string where = "")
        {
            string        cmdText  = string.Empty;
            IDbSchema     dbSchema = this.Database.Parent;
            StringBuilder sb       = new StringBuilder();

            columnList.ForEach(s => sb.AppendFormat("{0},", dbSchema.QuoteIdentifier(s)));

            if (!string.IsNullOrEmpty(where))
            {
                cmdText = string.Format("SELECT {0} FROM {0} WHERE {2}", sb.ToString().TrimEnd(','), this.Name, where);
            }
            else
            {
                cmdText = string.Format("SELECT {0} FROM {0}", sb.ToString().TrimEnd(','), this.Name);
            }

            DataTable dt = dbSchema.ExecuteQuery(this.Database, cmdText).Tables[0];

            return(dt);
        }