public void TestQueryWithRowDelegate()
        {
            RowDelegate handler = new RowDelegate(this.RowHandler);

            IList list = dataMapper.QueryWithRowDelegate("GetAllAccountsViaResultMap", null, handler);

            Assert.AreEqual(5, _index);
            Assert.AreEqual(5, list.Count);
            AssertAccount1((Account)list[0]);
            Assert.AreEqual(1, ((Account)list[0]).Id);
            Assert.AreEqual(2, ((Account)list[1]).Id);
            Assert.AreEqual(3, ((Account)list[2]).Id);
            Assert.AreEqual(4, ((Account)list[3]).Id);
            Assert.AreEqual(5, ((Account)list[4]).Id);
        }
Beispiel #2
0
        public static bool DetailsRow <T>(string name, ref T value, RowDelegate <T> selector)
        {
            ImGui.PushID(name.GetHashCode());

            ImGui.AlignTextToFramePadding();
            ImGui.TreeNodeEx(name, RowFlags);
            ImGui.NextColumn();
            ImGui.SetNextItemWidth(-1);

            var changed = selector(ref value);

            ImGui.NextColumn();
            ImGui.PopID();

            return(changed);
        }
Beispiel #3
0
        public void TestQueryWithRowDelegate()
        {
            _index = 0;
            RowDelegate <Account> handler = new RowDelegate <Account>(this.RowHandler);

            IList <Account> list = sqlMap.QueryWithRowDelegate <Account>("GetAllAccountsViaResultMap", null, handler);

            Assert.AreEqual(5, _index);
            Assert.AreEqual(5, list.Count);
            AssertAccount1(list[0]);
            Assert.AreEqual(1, list[0].Id);
            Assert.AreEqual(2, list[1].Id);
            Assert.AreEqual(3, list[2].Id);
            Assert.AreEqual(4, list[3].Id);
            Assert.AreEqual(5, list[4].Id);
        }
Beispiel #4
0
 public static void AddOnRepacked(RowDelegate <DefinicjaPunktuRow> value)
 => OnRepacked = (RowDelegate <DefinicjaPunktuRow>)Delegate.Combine(OnRepacked, value);
Beispiel #5
0
 public static void AddDefinicjaAfterEdit(RowDelegate <PunktRow> value)
 => DefinicjaAfterEdit = (RowDelegate <PunktRow>)Delegate.Combine(DefinicjaAfterEdit, value);
Beispiel #6
0
 public static void AddAutorAfterEdit(RowDelegate <CommitRow> value)
 => AutorAfterEdit = (RowDelegate <CommitRow>)Delegate.Combine(AutorAfterEdit, value);
Beispiel #7
0
 public static void AddSHAAfterEdit(RowDelegate <CommitRow> value)
 => SHAAfterEdit = (RowDelegate <CommitRow>)Delegate.Combine(SHAAfterEdit, value);
Beispiel #8
0
 /// <summary>
 /// Runs a query for list with a custom object that gets a chance to deal
 /// with each row as it is processed.
 /// <p/>
 /// The parameter object is generally used to supply the input
 /// data for the WHERE clause parameter(s) of the SELECT statement.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="statementId">The statement id.</param>
 /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
 /// <param name="rowDelegate">The row delegate.</param>
 /// <returns>A List of result objects.</returns>
 public IList <T> QueryWithRowDelegate <T>(string statementId, object parameterObject, RowDelegate <T> rowDelegate)
 {
     using (var sessionScope = new DataMapperLocalSessionScope(sessionStore, sessionFactory))
     {
         IMappedStatement statement = GetMappedStatement(statementId);
         return(statement.ExecuteQueryForRowDelegate(sessionScope.Session, parameterObject, rowDelegate));
     }
 }
Beispiel #9
0
        public virtual IList <T> ExecuteQueryForRowDelegate <T>(ISqlMapSession session, object parameterObject, RowDelegate <T> rowDelegate)
        {
            RequestScope request = this._statement.Sql.GetRequestScope(this, parameterObject, session);

            this._preparedCommand.Create(request, session, this.Statement, parameterObject);
            if (rowDelegate == null)
            {
                throw new DataMapperException("A null RowDelegate was passed to QueryForRowDelegate.");
            }
            return(this.RunQueryForList <T>(request, session, parameterObject, null, rowDelegate));
        }
Beispiel #10
0
        /// <summary>
        /// Runs a query with a custom object that gets a chance
        /// to deal with each row as it is processed.
        /// </summary>
        /// <param name="session">The session used to execute the statement.</param>
        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
        /// <param name="rowDelegate"></param>
        public virtual IList <T> ExecuteQueryForRowDelegate <T>(ISession session, object parameterObject, RowDelegate <T> rowDelegate)
        {
            if (rowDelegate == null)
            {
                throw new DataMapperException("A null RowDelegate was passed to QueryForRowDelegate.");
            }

            return(Execute(PreSelectEventKey, PostSelectEventKey, session, parameterObject,
                           (r, p) => RunQueryForList(r, session, p, null, rowDelegate)));
        }
Beispiel #11
0
 public static void AddOnDeleted(RowDelegate <PunktRow> value)
 => OnDeleted = (RowDelegate <PunktRow>)Delegate.Combine(OnDeleted, value);
 protected IList <T> QueryWithRowDelegate <T>(string statementName, object parameterObject,
                                              RowDelegate <T> rowDelegate)
 {
     return(mapper.QueryWithRowDelegate <T>(statementName, parameterObject, rowDelegate));
 }
Beispiel #13
0
 public static void AddOnEditing(RowDelegate <PunktRow> value)
 => OnEditing = (RowDelegate <PunktRow>)Delegate.Combine(OnEditing, value);
Beispiel #14
0
 public static void AddLiczbaNalezna2AfterEdit(RowDelegate <PunktRow> value)
 => LiczbaNalezna2AfterEdit = (RowDelegate <PunktRow>)Delegate.Combine(LiczbaNalezna2AfterEdit, value);
Beispiel #15
0
 public static void AddLiczbaNalezna2BeforeEdit(RowDelegate <PunktRow, int> value)
 => LiczbaNalezna2BeforeEdit = (RowDelegate <PunktRow, int>)Delegate.Combine(LiczbaNalezna2BeforeEdit, value);
Beispiel #16
0
        /// <summary>
        /// Executes the SQL and retuns a List of result objects.
        /// </summary>
        /// <param name="request">The request scope.</param>
        /// <param name="session">The session used to execute the statement.</param>
        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
        /// <param name="resultObject">The result object</param>
        /// <param name="rowDelegate"></param>
        /// <returns>A List of result objects.</returns>
        internal IList <T> RunQueryForList <T>(RequestScope request, ISession session, object parameterObject, IList <T> resultObject, RowDelegate <T> rowDelegate)
        {
            IList <T> list = resultObject;

            using (IDbCommand command = request.IDbCommand)
            {
                if (resultObject == null)
                {
                    if (statement.ListClass == null)
                    {
                        list = new List <T>();
                    }
                    else
                    {
                        list = statement.CreateInstanceOfGenericListClass <T>();
                    }
                }

                IDataReader reader = command.ExecuteReader();
                try
                {
                    do
                    {
                        if (rowDelegate == null)
                        {
                            while (reader.Read())
                            {
                                object obj = resultStrategy.Process(request, ref reader, null);
                                if (obj != BaseStrategy.SKIP)
                                {
                                    list.Add((T)obj);
                                }
                            }
                        }
                        else
                        {
                            while (reader.Read())
                            {
                                T obj = (T)resultStrategy.Process(request, ref reader, null);
                                rowDelegate(obj, parameterObject, list);
                            }
                        }
                    }while (reader.NextResult());
                }
                finally
                {
                    reader.Close();
                    reader.Dispose();
                }

                ExecuteDelayedLoad(request);
                RetrieveOutputParameters(request, session, command, parameterObject);
            }

            return(list);
        }
Beispiel #17
0
        internal IList <T> RunQueryForList <T>(RequestScope request, ISqlMapSession session, object parameterObject, IList <T> resultObject, RowDelegate <T> rowDelegate)
        {
            IList <T> list = resultObject;

            using (IDbCommand command = request.IDbCommand)
            {
                if (resultObject == null)
                {
                    if (this._statement.ListClass == null)
                    {
                        list = new List <T>();
                    }
                    else
                    {
                        list = this._statement.CreateInstanceOfGenericListClass <T>();
                    }
                }
                IDataReader reader = command.ExecuteReader();
                try
                {
                    T local;
Label_0036:
                    if (rowDelegate != null)
                    {
                        goto Label_0090;
                    }
                    while (reader.Read())
                    {
                        object obj2 = this._resultStrategy.Process(request, ref reader, null);
                        if (obj2 != BaseStrategy.SKIP)
                        {
                            list.Add((T)obj2);
                        }
                    }
                    goto Label_0098;
Label_006A:
                    local = (T)this._resultStrategy.Process(request, ref reader, null);
                    rowDelegate(local, parameterObject, list);
Label_0090:
                    if (reader.Read())
                    {
                        goto Label_006A;
                    }
Label_0098:
                    if (reader.NextResult())
                    {
                        goto Label_0036;
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    reader.Close();
                    reader.Dispose();
                }
                this.ExecutePostSelect(request);
                this.RetrieveOutputParameters(request, session, command, parameterObject);
            }
            return(list);
        }
Beispiel #18
0
 /// <summary>
 /// Runs a query with a custom object that gets a chance
 /// to deal with each row as it is processed.
 /// </summary>
 /// <param name="session">The session used to execute the statement.</param>
 /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
 /// <param name="rowDelegate"></param>
 public virtual IList ExecuteQueryForRowDelegate(ISession session, object parameterObject, RowDelegate rowDelegate)
 {
     return(Execute(PreSelectEventKey, PostSelectEventKey, session, parameterObject,
                    (r, p) => RunQueryForList(r, session, p, null, rowDelegate)));
 }
Beispiel #19
0
        internal IList RunQueryForList(RequestScope request, ISqlMapSession session, object parameterObject, IList resultObject, RowDelegate rowDelegate)
        {
            IList list = resultObject;

            using (IDbCommand command = request.IDbCommand)
            {
                if (resultObject == null)
                {
                    if (this._statement.ListClass == null)
                    {
                        list = new ArrayList();
                    }
                    else
                    {
                        list = this._statement.CreateInstanceOfListClass();
                    }
                }
                IDataReader reader = command.ExecuteReader();
                try
                {
                    object obj3;
Label_0036:
                    if (rowDelegate != null)
                    {
                        goto Label_0082;
                    }
                    while (reader.Read())
                    {
                        object obj2 = this._resultStrategy.Process(request, ref reader, null);
                        if (obj2 != BaseStrategy.SKIP)
                        {
                            list.Add(obj2);
                        }
                    }
                    goto Label_008A;
Label_0066:
                    obj3 = this._resultStrategy.Process(request, ref reader, null);
                    rowDelegate(obj3, parameterObject, list);
Label_0082:
                    if (reader.Read())
                    {
                        goto Label_0066;
                    }
Label_008A:
                    if (reader.NextResult())
                    {
                        goto Label_0036;
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    reader.Close();
                    reader.Dispose();
                }
                this.ExecutePostSelect(request);
                this.RetrieveOutputParameters(request, session, command, parameterObject);
            }
            return(list);
        }
        public IList <T> QueryWithRowDelegate <T>(string statementName, object parameterObject, RowDelegate <T> rowDelegate)
        {
            bool           flag         = false;
            ISqlMapSession localSession = this._sessionStore.LocalSession;
            IList <T>      list         = null;

            if (localSession == null)
            {
                localSession = this.CreateSqlMapSession();
                flag         = true;
            }
            try
            {
                list = this.GetMappedStatement(statementName).ExecuteQueryForRowDelegate <T>(localSession, parameterObject, rowDelegate);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (flag)
                {
                    localSession.CloseConnection();
                }
            }
            return(list);
        }
Beispiel #21
0
        public void TestQueryWithRowDelegate()
        {
            RowDelegate handler = new RowDelegate(this.RowHandler);

            IList list = sqlMap.QueryWithRowDelegate("GetAllAccountsViaResultMap", null, handler);

            Assert.AreEqual(5, _index);
            Assert.AreEqual(5, list.Count);
            AssertAccount1((Account)list[0]);
            Assert.AreEqual(1, ((Account)list[0]).Id);
            Assert.AreEqual(2, ((Account)list[1]).Id);
            Assert.AreEqual(3, ((Account)list[2]).Id);
            Assert.AreEqual(4, ((Account)list[3]).Id);
            Assert.AreEqual(5, ((Account)list[4]).Id);
        }
Beispiel #22
0
        public void TestQueryWithRowDelegate()
        {
            _index = 0;
            RowDelegate<Account> handler = new RowDelegate<Account>(this.RowHandler);

            IList<Account> list = sqlMap.QueryWithRowDelegate<Account>("GetAllAccountsViaResultMap", null, handler);

            Assert.AreEqual(5, _index);
            Assert.AreEqual(5, list.Count);
            AssertAccount1(list[0]);
            Assert.AreEqual(1, list[0].Id);
            Assert.AreEqual(2, list[1].Id);
            Assert.AreEqual(3, list[2].Id);
            Assert.AreEqual(4, list[3].Id);
            Assert.AreEqual(5, list[4].Id);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="session"></param>
 /// <param name="parameterObject"></param>
 /// <param name="rowDelegate"></param>
 /// <returns></returns>
 public override IList ExecuteQueryForRowDelegate(ISqlMapSession session, object parameterObject, RowDelegate rowDelegate )
 {
     throw new DataMapperException("Insert statements cannot be executed as a query for row delegate.");
 }
Beispiel #24
0
 /// <summary>
 /// Runs a query with a custom object that gets a chance
 /// to deal with each row as it is processed.
 /// </summary>
 /// <param name="session">The session used to execute the statement.</param>
 /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
 /// <param name="rowDelegate"></param>
 public IList <T> ExecuteQueryForRowDelegate <T>(ISqlMapSession session, object parameterObject, RowDelegate <T> rowDelegate)
 {
     return(_mappedStatement.ExecuteQueryForRowDelegate <T>(session, parameterObject, rowDelegate));
 }
Beispiel #25
0
 public static void AddDataAfterEdit(RowDelegate <CommitRow> value)
 => DataAfterEdit = (RowDelegate <CommitRow>)Delegate.Combine(DataAfterEdit, value);
Beispiel #26
0
 public static void AddAutorBeforeEdit(RowDelegate <CommitRow, string> value)
 => AutorBeforeEdit = (RowDelegate <CommitRow, string>)Delegate.Combine(AutorBeforeEdit, value);
Beispiel #27
0
 public static void AddOnRepacked(RowDelegate <CommitRow> value)
 => OnRepacked = (RowDelegate <CommitRow>)Delegate.Combine(OnRepacked, value);
Beispiel #28
0
 public static void AddDataBeforeEdit(RowDelegate <CommitRow, Date> value)
 => DataBeforeEdit = (RowDelegate <CommitRow, Date>)Delegate.Combine(DataBeforeEdit, value);
Beispiel #29
0
 public static void AddDefinicjaBeforeEdit(RowDelegate <PunktRow, DefinicjaPunktu> value)
 => DefinicjaBeforeEdit = (RowDelegate <PunktRow, DefinicjaPunktu>)Delegate.Combine(DefinicjaBeforeEdit, value);
Beispiel #30
0
 public static void AddOnDeleting(RowDelegate <CommitRow> value)
 => OnDeleting = (RowDelegate <CommitRow>)Delegate.Combine(OnDeleting, value);
Beispiel #31
0
 /// <summary>
 /// Runs a query with a custom object that gets a chance
 /// to deal with each row as it is processed.
 /// </summary>
 /// <remarks>
 /// This method always bypasses the cache.
 /// </remarks>
 /// <param name="session">The session used to execute the statement.</param>
 /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
 /// <param name="rowDelegate"></param>
 public IList <T> ExecuteQueryForRowDelegate <T>(ISession session, object parameterObject, RowDelegate <T> rowDelegate)
 {
     // TODO: investigate allow the cached data to be processed by a different rowDelegate...add rowDelegate to the CacheKey ???
     return(mappedStatement.ExecuteQueryForRowDelegate(session, parameterObject, rowDelegate));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="session"></param>
 /// <param name="parameterObject"></param>
 /// <param name="rowDelegate"></param>
 /// <returns></returns>
 public override IList ExecuteQueryForRowDelegate(ISqlMapSession session, object parameterObject, RowDelegate rowDelegate)
 {
     throw new DataMapperException("Update statement cannot be executed as a query for row delegate.");
 }
Beispiel #33
0
        /// <summary>
        /// Executes the SQL and retuns a List of result objects.
        /// </summary>
        /// <param name="request">The request scope.</param>
        /// <param name="session">The session used to execute the statement.</param>
        /// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
        /// <param name="resultObject">A strongly typed collection of result objects.</param>
        /// <param name="rowDelegate"></param>
        /// <returns>A List of result objects.</returns>
        internal IList RunQueryForList(RequestScope request, ISession session, object parameterObject, IList resultObject, RowDelegate rowDelegate)
        {
            IList list = resultObject;

            using (IDbCommand command = request.IDbCommand)
            {
                if (resultObject == null)
                {
                    if (statement.ListClass == null)
                    {
                        list = new ArrayList();
                    }
                    else
                    {
                        list = statement.CreateInstanceOfListClass();
                    }
                }

                IDataReader reader = command.ExecuteReader();

                try
                {
                    do
                    {
                        if (rowDelegate == null)
                        {
                            //***
                            IList currentList = null;
                            if (request.Statement.ResultsMap.Count == 1)
                            {
                                currentList = list;
                            }
                            else
                            {
                                if (request.CurrentResultMap != null)
                                {
                                    Type genericListType = typeof(List <>).MakeGenericType(new Type[] { request.CurrentResultMap.Class });
                                    currentList = (IList)Activator.CreateInstance(genericListType);
                                }
                                else
                                {
                                    currentList = new ArrayList();
                                }
                                list.Add(currentList);
                            }
                            //***
                            while (reader.Read())
                            {
                                //将reader当前行中的所有字段加入到IList对象中,即obj中
                                object obj = resultStrategy.Process(request, ref reader, null);
                                if (obj != BaseStrategy.SKIP)
                                {
                                    //list.Add(obj);
                                    currentList.Add(obj);
                                }
                            }
                        }
                        else
                        {
                            while (reader.Read())
                            {
                                object obj = resultStrategy.Process(request, ref reader, null);
                                rowDelegate(obj, parameterObject, list);
                            }
                        }
                    }while (reader.NextResult());
                }
                finally
                {
                    reader.Close();
                    reader.Dispose();
                }

                ExecuteDelayedLoad(request);
                RetrieveOutputParameters(request, session, command, parameterObject);
            }

            return(list);
        }