示例#1
0
        /// <summary>
        /// Override of <see cref="object.Equals(object)"/> method for <see cref="SQLQuery"/>.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            SQLQuery <T> sqlQueryObj = obj as SQLQuery <T>;

            if (sqlQueryObj == null)
            {
                return(false);
            }
            else
            {
                return(Equals(sqlQueryObj));
            }
        }
示例#2
0
        /// <summary>
        /// <para>Implementation of <see cref="IEquatable{T}"/> for <see cref="SQLQuery"/>.</para>
        /// <para>Returns true if <see cref="SQLQuery"/> references the same <see cref="object"/> or its members are equal.</para>
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(SQLQuery <T> other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(SQL.Equals(other.SQL) &&
                   DbTableName.Equals(other.DbTableName) &&
                   TObjects.Equals(other.TObjects) &&
                   CommandType.Equals(other.CommandType) &&
                   IsBulk.Equals(other.IsBulk) &&
                   BatchSize.Equals(other.BatchSize));
        }
示例#3
0
 protected List <T> Query <T>(SQLQuery <T> sqlQuery) where T : class
 {
     using (var dbconnection = new SqlConnection(_connectionString))
     {
         var result = new List <T>();
         if (sqlQuery.TObjects == null)
         {
             var response = dbconnection.Query <T>(sqlQuery.SQL, commandType: sqlQuery.CommandType);
             result.AddRange(response);
         }
         else
         {
             foreach (var TObject in sqlQuery.TObjects)
             {
                 var response = dbconnection.Query <T>(sqlQuery.SQL, TObject, commandType: sqlQuery.CommandType);
                 result.AddRange(response);
             }
         }
         return(result);
     }
 }
示例#4
0
 protected int Execute <T>(SQLQuery <T> sqlQuery) where T : class
 {
     return(Execute(new List <SQLQuery <T> > {
         sqlQuery
     })[0]);
 }
示例#5
0
 protected int Update <T>(SQLQuery <T> sqlQuery) where T : class
 {
     return(Execute(sqlQuery));
 }
示例#6
0
 protected int Insert <T>(SQLQuery <T> sqlQuery) where T : class
 {
     return(Execute(sqlQuery));
 }
示例#7
0
 protected List <T> Select <T>(SQLQuery <T> sqlQuery) where T : class
 {
     return(Query(sqlQuery));
 }