public override IDbCommand BuildForCriteria(PersistentCriteria criteria)
        {
            string filterClause = SqlStatement.BuildForFilters(criteria.Filters);

            if (filterClause == null || filterClause.Equals(""))
            {
                m_SqlString = m_SelectFromClause;
            }
            else
            {
                m_SqlString = m_SelectFromClause + " WHERE " + filterClause;
            }

            ArrayList orderList = ((RetrieveCriteria)criteria).OrderList;

            if (orderList != null)
            {
                m_SqlString += this.GetOrderBySql(orderList, ThisClassMap);
            }

            IDbCommand cmd = ThisClassMap.PersistenceProvider.GetCommand();

            cmd.CommandText = this.SqlString;
            return(cmd);
        }
Example #2
0
        public override IDbCommand BuildForCriteria(PersistentCriteria criteria)
        {
            string filterClause = SqlStatement.BuildForFilters(criteria.Filters);

            if (filterClause == null || filterClause.Equals(""))
            {
                m_SqlString = m_DeleteFromClause;
            }
            else
            {
                m_SqlString = m_DeleteFromClause + " WHERE " + filterClause;
            }

            IDbCommand cmd = ThisClassMap.PersistenceProvider.GetCommand();

            cmd.CommandText = this.SqlString;
            return(cmd);
        }
        public override IDbCommand BuildForCriteria(PersistentCriteria criteria)
        {
            AttributeMap attrMap;
            bool         isFirst      = true;
            string       filterClause = SqlStatement.BuildForFilters(criteria.Filters);
            string       updateClause = "";

            IDbCommand cmd = ThisClassMap.PersistenceProvider.GetCommand();

            foreach (DictionaryEntry updateField in ((UpdateCriteria)criteria).ForUpdateCollection)
            {
                attrMap = m_ClassMap.GetAttributeMap(updateField.Key.ToString());

                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    updateClause += ",";
                }

                updateClause += attrMap.Column.Name + "=" + ThisClassMap.PersistenceProvider.GetStringParameter(attrMap.Column.Name);

                IDataParameter p = cmd.CreateParameter();
                p.ParameterName = "@" + attrMap.Column.Name;
                p.DbType        = attrMap.Column.Type;
                p.Value         = updateField.Value;
                cmd.Parameters.Add(p);
            }

            if (filterClause == null || filterClause.Equals(""))
            {
                m_SqlString = m_UpdateFromClause + updateClause;
            }
            else
            {
                m_SqlString = m_UpdateFromClause + updateClause + " WHERE " + filterClause;
            }

            cmd.CommandText = this.SqlString;

            return(cmd);
        }
 public override IDbCommand BuildForCriteria(PersistentCriteria criteria)
 {
     throw new NotImplementedException();
 }