Esempio n. 1
0
        private static RecordTable CreateDataSource(GridColumnInfo info, IDbAccess dataAccess)
        {
            SqlQuery query = new SqlQuery();
            StringBuilder text = query.Text;
            text.Append("SELECT ");
            text.Append(info.ParentValueField);
            text.Append(',');
            text.Append(info.ParentTextField);
            text.Append(" FROM ");
            text.Append(info.ParentTable);

            if (!String.IsNullOrEmpty(info.FilterExpression))
            {
                text.Append(" WHERE ");
                text.Append(info.FilterExpression);
            }
            if (!String.IsNullOrEmpty(info.SortExpression))
            {
                text.Append(" ORDER BY ");
                text.Append(info.SortExpression);
            }

            RecordTable table = new RecordTable(info.ParentTable);
            using(IDataReader dr = dataAccess.CreateDataReader(query, CommandBehavior.Default))
            {
                table.Load(dr, false, new UISchemaTableReader(info.ParentValueField));
            }
            return table;
        }