예제 #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;
        }
예제 #2
0
        internal RecordCollection(RecordTable table)
        {
            this.table = table;
            this.dic = new RecordDictionary();
            this.list = new ReadOnlyCollection<Record>(new List<Record>());

        }
예제 #3
0
        public void DataBind()
        {
            if (this.IsAutoDataBindingEnabled)
            {
                if (!String.IsNullOrEmpty(this.columnInfoList.TableName) && !String.IsNullOrEmpty(this.columnInfoList.KeyName))
                {
                    SqlQuery query = new SqlQuery();
                    StringBuilder text = query.Text;
                    text.Append("SELECT ");
                    text.Append(this.columnInfoList.KeyName);
                    text.Append(',');

                    foreach(GridColumnInfo info in this.columnInfoList)
                    {
                        text.Append(info.PropertyName);
                        text.Append(',');
                    }

                    text.Remove(text.Length - 1, 1);

                    text.Append(" FROM ");
                    text.Append(this.columnInfoList.TableName);

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

                    RecordTable table = new RecordTable(this.columnInfoList.TableName);
                    using(IDataReader dr = this.Factory.DataAccess.CreateDataReader(query, CommandBehavior.Default))
                    {
                        table.Load(dr, true, new UISchemaTableReader(this.columnInfoList.KeyName));
                    }

                    base.ItemsSource = table;
                }
            }
        }
예제 #4
0
 private void CreateDataSource(SqlQuery query)
 {
     this.table = new RecordTable();
     using (IDataReader dr = this.factory.DataAccess.CreateDataReader(query, System.Data.CommandBehavior.Default))
     {
         this.table.Load(dr, false, new UISchemaTableReader(this.ParentValueField));
     }
 }
예제 #5
0
        private static RecordTable Clone(RecordTable orginalTable, IEnumerable<Record> filteredRecords)
        {
            RecordTable clone = orginalTable.Clone();
            foreach (Record record in filteredRecords)
            {
                Record newRecord = clone.NewRecord();
                foreach (SchemaInfo schema in clone.Schemas)
                {
                    newRecord[schema.ColumnName] = record[schema.ColumnName];
                }

                clone.Add(newRecord);
            }

            return clone;
        }
예제 #6
0
 private static List<SchemaInfo> GetFilterColumns(RecordTable table, Predicate<SchemaInfo> match)
 {
     bool isPredicateEnable = null != match;
     ICollection<SchemaInfo> clmns = table.Schemas;
     List<SchemaInfo> ret = new List<SchemaInfo>();
     foreach (SchemaInfo clmn in clmns)
     {
         if (isPredicateEnable && !match(clmn))
         {
             continue;
         }
         ret.Add(clmn);
     }
     return ret;
 }