Пример #1
0
        /// <see cref="NI.Data.IDalc.Load(NI.Data.Query,System.Data.DataSet)"/>
        public virtual DataTable Load(Query query, DataSet ds)
        {
            using (var selectCmd = CommandGenerator.ComposeSelect(query)) {
                QTable source = query.Table;

                selectCmd.Connection = Connection;

                OnCommandExecuting(source.Name, StatementType.Select, selectCmd);

                var adapter = DbFactory.CreateDataAdapter(OnRowUpdating, OnRowUpdated);
                try {
                    adapter.SelectCommand = selectCmd;
                    if (adapter is DbDataAdapter)
                    {
                        ((DbDataAdapter)adapter).Fill(ds, query.StartRecord, query.RecordCount, source.Name);
                    }
                    else
                    {
                        adapter.Fill(ds);
                    }
                } finally {
                    // some implementations are sensitive to explicit dispose
                    if (adapter is IDisposable)
                    {
                        ((IDisposable)adapter).Dispose();
                    }
                }

                OnCommandExecuted(source.Name, StatementType.Select, selectCmd);
                return(ds.Tables[source.Name]);
            }
        }
Пример #2
0
        protected virtual string GetTableName(string tableName)
        {
            QTable table = (QTable)tableName;

            if (!String.IsNullOrEmpty(table.Alias))
            {
                return(table.Name + " " + table.Alias);
            }
            return(table.Name);
        }
Пример #3
0
        /// <summary>
        /// Load all records by query
        /// </summary>
        /// <param name="q">query</param>
        /// <returns>DataTable filled with data that matched specified query</returns>
        public DataTable LoadAll(Query q)
        {
            QTable  source = new QTable(q.Table);
            DataSet ds     = CreateDataSet(source.Name);

            if (ds == null)
            {
                ds = new DataSet();
            }
            var tbl = Dalc.Load(q, ds);

            return(tbl);
        }
Пример #4
0
        /// <summary>
        /// Load DataRow by query
        /// </summary>
        /// <param name="q">query</param>
        /// <returns>DataRow or null if no records matched</returns>
        public DataRow Load(Query q)
        {
            QTable  table = new QTable(q.Table);
            DataSet ds    = CreateDataSet(table.Name);

            if (ds == null)
            {
                ds = new DataSet();
            }
            var tbl = Dalc.Load(q, ds);

            return(tbl.Rows.Count > 0 ? tbl.Rows[0] : null);
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the Query with identical options of specified query
 /// </summary>
 /// <param name="q">query with options to copy</param>
 public Query(Query q)
 {
     _Table       = q.Table;
     _Sort        = q.Sort;
     _StartRecord = q.StartRecord;
     _RecordCount = q.RecordCount;
     Condition    = q.Condition;
     _Fields      = q.Fields;
     if (q.ExtendedProperties != null)
     {
         ExtendedProperties = new Dictionary <string, object>(q.ExtendedProperties);
     }
 }
Пример #6
0
        /// <summary>
        /// Load all objects matched by query
        /// </summary>
        /// <param name="q">query</param>
        /// <returns>list of matched objects</returns>
        public IEnumerable <T> LoadAll(Query q)
        {
            var ds = new DataSet();

            DbManager.Dalc.Load(q, ds);
            var srcName = new QTable(q.Table);
            var rs      = new List <T>();

            foreach (DataRow r in ds.Tables[srcName.Name].Rows)
            {
                var t = new T();
                CopyDataRowToObject(r, t);
                rs.Add(t);
            }
            return(rs);
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the Query with specified table and condition
 /// </summary>
 /// <param name="table">target table</param>
 /// <param name="condition">condition represented by QueryNode</param>
 public Query(QTable table, QueryNode condition)
 {
     _Table    = table;
     Condition = condition;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the Query with specified table name and condition node
 /// </summary>
 /// <param name="tableName">target table name</param>
 /// <param name="condition">condition represented by QueryNode</param>
 public Query(string tableName, QueryNode condition)
 {
     _Table    = tableName;
     Condition = condition;
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the Query with specified table
 /// </summary>
 /// <param name="table">target table</param>
 public Query(QTable table)
 {
     _Table = table;
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the Query with specified table name
 /// </summary>
 /// <param name="tableName">target table name</param>
 public Query(string tableName)
 {
     _Table = new QTable(tableName);
 }
Пример #11
0
 public virtual bool IsMatchTable(QTable table)
 {
     return(TableName == table.Name);
 }