using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;
using Dapper;
using PushPlatform.Data;

namespace PushPlatform.Data.DaoAchieve
{
    sealed partial class PushMessageDaoAchieve
    {
        
        
        
        
        #region Dao
        public int Save(PushMessage entity)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("Insert into push_message values (@Id,@Map_Id,@User_Id,@Send_Number,@PushSys_ProId,@Project_Id,@Push_Target,@Push_Style,@Push_TagId,@Push_Title,@Push_Body,@Push_IosLink,@Push_AndLink,@Push_WebLink,@Push_WechatLink,@Have_Send,@Is_Successed,@Send_Time,@Return_Code,@HaveRead,@Is_Deleted,@Create_User,@Create_Time,@Update_User,@Update_Time,@Timestamp)",
                                   entity);
                return result;
            }
        }
        
        public int Save(List<PushMessage> entityList)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("Insert into push_message values (@Id,@Map_Id,@User_Id,@Send_Number,@PushSys_ProId,@Project_Id,@Push_Target,@Push_Style,@Push_TagId,@Push_Title,@Push_Body,@Push_IosLink,@Push_AndLink,@Push_WebLink,@Push_WechatLink,@Have_Send,@Is_Successed,@Send_Time,@Return_Code,@HaveRead,@Is_Deleted,@Create_User,@Create_Time,@Update_User,@Update_Time,@Timestamp)",
                                   entityList);
                return result;
            }
        }
        
        
        public int Delete(string id)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("delete from push_message where Id=@id",
                                   new { id = id });
                return result;
            }
        }
        
        public int Update(PushMessage entity)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("update push_message set Map_Id=@Map_Id,User_Id=@User_Id,Send_Number=@Send_Number,PushSys_ProId=@PushSys_ProId,Project_Id=@Project_Id,Push_Target=@Push_Target,Push_Style=@Push_Style,Push_TagId=@Push_TagId,Push_Title=@Push_Title,Push_Body=@Push_Body,Push_IosLink=@Push_IosLink,Push_AndLink=@Push_AndLink,Push_WebLink=@Push_WebLink,Push_WechatLink=@Push_WechatLink,Have_Send=@Have_Send,Is_Successed=@Is_Successed,Send_Time=@Send_Time,Return_Code=@Return_Code,HaveRead=@HaveRead,Is_Deleted=@Is_Deleted,Create_User=@Create_User,Create_Time=@Create_Time,Update_User=@Update_User,Update_Time=@Update_Time,Timestamp=@Timestamp where Id=@id",
                                   entity);
                return result;
            }
        }
        
        public int Update(List<PushMessage> entityList)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("update push_message set Map_Id=@Map_Id,User_Id=@User_Id,Send_Number=@Send_Number,PushSys_ProId=@PushSys_ProId,Project_Id=@Project_Id,Push_Target=@Push_Target,Push_Style=@Push_Style,Push_TagId=@Push_TagId,Push_Title=@Push_Title,Push_Body=@Push_Body,Push_IosLink=@Push_IosLink,Push_AndLink=@Push_AndLink,Push_WebLink=@Push_WebLink,Push_WechatLink=@Push_WechatLink,Have_Send=@Have_Send,Is_Successed=@Is_Successed,Send_Time=@Send_Time,Return_Code=@Return_Code,HaveRead=@HaveRead,Is_Deleted=@Is_Deleted,Create_User=@Create_User,Create_Time=@Create_Time,Update_User=@Update_User,Update_Time=@Update_Time,Timestamp=@Timestamp where Id=@id",
                                   entityList);
                return result;
            }
        }
        
        public int SaveOrUpdate(IList<PushMessage> entityList)
        {
            if (entityList == null || entityList.Count == 0)
                return 0;
            List<PushMessage> saveList = new List<PushMessage>();
            List<PushMessage> updateList = new List<PushMessage>();
            foreach(var entity in entityList)
            {
                if(entity.IsEdit)
                {
                    updateList.Add(entity);
                }
                else
                {
                    saveList.Add(entity);
                }
            }
            int save = 0;
            int update = 0;
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
		connection.Open();
                IDbTransaction transaction = connection.BeginTransaction();
                try
                {
                    if (updateList.Count > 0)
                    {
                        update = connection.Execute("update push_message set Map_Id=@Map_Id,User_Id=@User_Id,Send_Number=@Send_Number,PushSys_ProId=@PushSys_ProId,Project_Id=@Project_Id,Push_Target=@Push_Target,Push_Style=@Push_Style,Push_TagId=@Push_TagId,Push_Title=@Push_Title,Push_Body=@Push_Body,Push_IosLink=@Push_IosLink,Push_AndLink=@Push_AndLink,Push_WebLink=@Push_WebLink,Push_WechatLink=@Push_WechatLink,Have_Send=@Have_Send,Is_Successed=@Is_Successed,Send_Time=@Send_Time,Return_Code=@Return_Code,HaveRead=@HaveRead,Is_Deleted=@Is_Deleted,Create_User=@Create_User,Create_Time=@Create_Time,Update_User=@Update_User,Update_Time=@Update_Time,Timestamp=@Timestamp where Id=@id",
                                       updateList, transaction, null, null);
                    }
                    if (saveList.Count > 0)
                    {
                        save = connection.Execute("Insert into push_message values (@Id,@Map_Id,@User_Id,@Send_Number,@PushSys_ProId,@Project_Id,@Push_Target,@Push_Style,@Push_TagId,@Push_Title,@Push_Body,@Push_IosLink,@Push_AndLink,@Push_WebLink,@Push_WechatLink,@Have_Send,@Is_Successed,@Send_Time,@Return_Code,@HaveRead,@Is_Deleted,@Create_User,@Create_Time,@Update_User,@Update_Time,@Timestamp)",
                                       saveList, transaction, null, null);
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new Exception(ex.Message);
                }
                return save + update;
            }
        }
        
        public int SaveOrUpdateWithTran(IList<PushMessage> entityList, IDbConnection connection, IDbTransaction transaction)
        {
            if (entityList == null || entityList.Count == 0)
                return 0;
            List<PushMessage> saveList = new List<PushMessage>();
            List<PushMessage> updateList = new List<PushMessage>();
            foreach(var entity in entityList)
            {
                if(entity.IsEdit)
                {
                    updateList.Add(entity);
                }
                else
                {
                    saveList.Add(entity);
                }
            }
            int save = 0;
            int update = 0;
            if (updateList.Count > 0)
            {
                update = connection.Execute("update push_message set Map_Id=@Map_Id,User_Id=@User_Id,Send_Number=@Send_Number,PushSys_ProId=@PushSys_ProId,Project_Id=@Project_Id,Push_Target=@Push_Target,Push_Style=@Push_Style,Push_TagId=@Push_TagId,Push_Title=@Push_Title,Push_Body=@Push_Body,Push_IosLink=@Push_IosLink,Push_AndLink=@Push_AndLink,Push_WebLink=@Push_WebLink,Push_WechatLink=@Push_WechatLink,Have_Send=@Have_Send,Is_Successed=@Is_Successed,Send_Time=@Send_Time,Return_Code=@Return_Code,HaveRead=@HaveRead,Is_Deleted=@Is_Deleted,Create_User=@Create_User,Create_Time=@Create_Time,Update_User=@Update_User,Update_Time=@Update_Time,Timestamp=@Timestamp where Id=@id",
                               updateList, transaction, null, null);
            }
            if (saveList.Count > 0)
            {
                save = connection.Execute("Insert into push_message values (@Id,@Map_Id,@User_Id,@Send_Number,@PushSys_ProId,@Project_Id,@Push_Target,@Push_Style,@Push_TagId,@Push_Title,@Push_Body,@Push_IosLink,@Push_AndLink,@Push_WebLink,@Push_WechatLink,@Have_Send,@Is_Successed,@Send_Time,@Return_Code,@HaveRead,@Is_Deleted,@Create_User,@Create_Time,@Update_User,@Update_Time,@Timestamp)",
                               saveList, transaction, null, null);
            }
            return save + update;
        }
        
        public PushMessage Get(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var query = connection.Query<PushMessage>("select * from push_message where Id=@id", new { id = id });
                if (query.Count() > 0)
                    return query.FirstOrDefault();
                return null;
            }
        }
        
        public int GetCount(PushPlatform.Data.Criteria.CriteriaPushMessage mycriteria)
        {
            if(mycriteria.UsePage && (mycriteria.PageIndex <= 0 || mycriteria.PageSize < 1))
            {
                mycriteria.PageTotal = 0;
                return 0;
            }
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                if (mycriteria.UserWhere)
                {
                    if (mycriteria.WhereValue != null)
                    {
                        return connection.Query<int>("select count(1) from push_message " + mycriteria.Where, mycriteria.WhereValue).FirstOrDefault();
                    }
                    else
                    {
                        return connection.Query<int>("select count(1) from push_message " + mycriteria.Where).FirstOrDefault();
                    }
                }
                else
                {
                    return connection.Query<int>("select count(1) from push_message " + CreatAutoQuery(mycriteria)).FirstOrDefault(); 
                }
            }
        }
        
        public List<PushMessage> Fetch(PushPlatform.Data.Criteria.CriteriaPushMessage mycriteria)
        {
            if(mycriteria.UsePage && (mycriteria.PageIndex <= 0 || mycriteria.PageSize < 1))
            {
                mycriteria.PageTotal = 0;
                return new List<PushMessage>();
            }
            string orderby = "";
            foreach(var order in mycriteria.OrderList)
            {
                if(orderby=="")
                {
                    orderby = " order by ";
                }
                orderby += order+",";
            }
            if(orderby.Length>0)
            {
                orderby = orderby.Substring(0, orderby.Length - 1);
                if(!mycriteria.IsAsc)
                {
                    orderby += " desc ";
                }
            }
            int pageStart = (mycriteria.PageIndex - 1) * mycriteria.PageSize;
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                if (mycriteria.UserWhere)
                {
                    if(mycriteria.UsePage)
                    {
                        if (mycriteria.WhereValue != null)
                        {
                            mycriteria.PageTotal = connection.Query<int>("select count(1) from push_message " + mycriteria.Where + orderby, mycriteria.WhereValue).FirstOrDefault();
                            var query = connection.Query<PushMessage>("select * from push_message " + mycriteria.Where + orderby + " LIMIT " + pageStart.ToString() + "," + mycriteria.PageSize, mycriteria.WhereValue);
                            return query.ToList();
                        }
                        else
                        {
                            mycriteria.PageTotal = connection.Query<int>("select count(1) from push_message " + mycriteria.Where + orderby).FirstOrDefault();
                            var query = connection.Query<PushMessage>("select * from push_message " + mycriteria.Where + orderby + " LIMIT " + pageStart.ToString() + "," + mycriteria.PageSize);
                            return query.ToList();
                        }
                    }
                    else
                    {
                        if (mycriteria.WhereValue != null)
                        {
                            var query = connection.Query<PushMessage>("select * from push_message " + mycriteria.Where + orderby, mycriteria.WhereValue);
                            return query.ToList();
                        }
                        else
                        {
                            var query = connection.Query<PushMessage>("select * from push_message " + mycriteria.Where + orderby);
                            return query.ToList();
                        }
                    }
                }
                else
                {
                    if (mycriteria.UsePage)
                    {
                        string whereStr=CreatAutoQuery(mycriteria);
                        mycriteria.PageTotal = connection.Query<int>("select count(1) from push_message " + whereStr).FirstOrDefault();
                        string queryStr = "select * from push_message ";
                        queryStr += whereStr + orderby;
                        queryStr += " LIMIT " + pageStart.ToString() + "," + mycriteria.PageSize;
                        var query = connection.Query<PushMessage>(queryStr);
                        return query.ToList();
                    }
                    else
                    {
                        string queryStr = "select * from push_message ";
                        queryStr += CreatAutoQuery(mycriteria) + orderby;
                        var query = connection.Query<PushMessage>(queryStr);
                        return query.ToList();
                    }  
                }
            }
        }
        #endregion
        
        #region method
        private string CreatAutoQuery(Criteria.CriteriaPushMessage mycriteria)
        {
            string where = "";
            
            if (!string.IsNullOrEmpty(mycriteria.LikeId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Id like '%" + mycriteria.LikeId + "%'";
            }
            if (mycriteria.InId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InId)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Id in (" + instr + ")";
            }
            if (mycriteria.NotId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotId)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Id not in (" + instr + ")";
            }
            if (mycriteria.OrEqId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqId)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Id='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeId)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Id like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Id ='" + mycriteria.EqId + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Id <>'" + mycriteria.NeId + "'";
            }
            if (mycriteria.NullId)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Id is null"; 
            }
            if (mycriteria.NotNullId)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Id is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeMapId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Map_Id like '%" + mycriteria.LikeMapId + "%'";
            }
            if (mycriteria.InMapId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InMapId)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Map_Id in (" + instr + ")";
            }
            if (mycriteria.NotMapId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotMapId)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Map_Id not in (" + instr + ")";
            }
            if (mycriteria.OrEqMapId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqMapId)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Map_Id='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeMapId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeMapId)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Map_Id like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqMapId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Map_Id ='" + mycriteria.EqMapId + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeMapId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Map_Id <>'" + mycriteria.NeMapId + "'";
            }
            if (mycriteria.NullMapId)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Map_Id is null"; 
            }
            if (mycriteria.NotNullMapId)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Map_Id is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeUserId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " User_Id like '%" + mycriteria.LikeUserId + "%'";
            }
            if (mycriteria.InUserId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InUserId)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " User_Id in (" + instr + ")";
            }
            if (mycriteria.NotUserId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotUserId)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "User_Id not in (" + instr + ")";
            }
            if (mycriteria.OrEqUserId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqUserId)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "User_Id='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeUserId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeUserId)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "User_Id like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqUserId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "User_Id ='" + mycriteria.EqUserId + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeUserId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "User_Id <>'" + mycriteria.NeUserId + "'";
            }
            if (mycriteria.NullUserId)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " User_Id is null"; 
            }
            if (mycriteria.NotNullUserId)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " User_Id is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeSendNumber))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Send_Number like '%" + mycriteria.LikeSendNumber + "%'";
            }
            if (mycriteria.InSendNumber.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InSendNumber)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Send_Number in (" + instr + ")";
            }
            if (mycriteria.NotSendNumber.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotSendNumber)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Send_Number not in (" + instr + ")";
            }
            if (mycriteria.OrEqSendNumber.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqSendNumber)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Send_Number='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeSendNumber.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeSendNumber)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Send_Number like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqSendNumber))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Send_Number ='" + mycriteria.EqSendNumber + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeSendNumber))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Send_Number <>'" + mycriteria.NeSendNumber + "'";
            }
            if (mycriteria.NullSendNumber)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Send_Number is null"; 
            }
            if (mycriteria.NotNullSendNumber)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Send_Number is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushsysProid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " PushSys_ProId like '%" + mycriteria.LikePushsysProid + "%'";
            }
            if (mycriteria.InPushsysProid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushsysProid)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " PushSys_ProId in (" + instr + ")";
            }
            if (mycriteria.NotPushsysProid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushsysProid)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "PushSys_ProId not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushsysProid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushsysProid)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "PushSys_ProId='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushsysProid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushsysProid)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "PushSys_ProId like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushsysProid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "PushSys_ProId ='" + mycriteria.EqPushsysProid + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushsysProid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "PushSys_ProId <>'" + mycriteria.NePushsysProid + "'";
            }
            if (mycriteria.NullPushsysProid)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " PushSys_ProId is null"; 
            }
            if (mycriteria.NotNullPushsysProid)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " PushSys_ProId is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeProjectId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Project_Id like '%" + mycriteria.LikeProjectId + "%'";
            }
            if (mycriteria.InProjectId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InProjectId)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Project_Id in (" + instr + ")";
            }
            if (mycriteria.NotProjectId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotProjectId)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Project_Id not in (" + instr + ")";
            }
            if (mycriteria.OrEqProjectId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqProjectId)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Project_Id='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeProjectId.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeProjectId)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Project_Id like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqProjectId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Project_Id ='" + mycriteria.EqProjectId + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeProjectId))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Project_Id <>'" + mycriteria.NeProjectId + "'";
            }
            if (mycriteria.NullProjectId)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Project_Id is null"; 
            }
            if (mycriteria.NotNullProjectId)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Project_Id is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushTarget))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Target like '%" + mycriteria.LikePushTarget + "%'";
            }
            if (mycriteria.InPushTarget.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushTarget)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_Target in (" + instr + ")";
            }
            if (mycriteria.NotPushTarget.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushTarget)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_Target not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushTarget.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushTarget)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_Target='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushTarget.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushTarget)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_Target like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushTarget))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_Target ='" + mycriteria.EqPushTarget + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushTarget))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_Target <>'" + mycriteria.NePushTarget + "'";
            }
            if (mycriteria.NullPushTarget)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Target is null"; 
            }
            if (mycriteria.NotNullPushTarget)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Target is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushStyle))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Style like '%" + mycriteria.LikePushStyle + "%'";
            }
            if (mycriteria.InPushStyle.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushStyle)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_Style in (" + instr + ")";
            }
            if (mycriteria.NotPushStyle.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushStyle)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_Style not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushStyle.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushStyle)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_Style='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushStyle.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushStyle)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_Style like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushStyle))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_Style ='" + mycriteria.EqPushStyle + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushStyle))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_Style <>'" + mycriteria.NePushStyle + "'";
            }
            if (mycriteria.NullPushStyle)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Style is null"; 
            }
            if (mycriteria.NotNullPushStyle)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Style is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushTagid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_TagId like '%" + mycriteria.LikePushTagid + "%'";
            }
            if (mycriteria.InPushTagid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushTagid)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_TagId in (" + instr + ")";
            }
            if (mycriteria.NotPushTagid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushTagid)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_TagId not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushTagid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushTagid)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_TagId='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushTagid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushTagid)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_TagId like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushTagid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_TagId ='" + mycriteria.EqPushTagid + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushTagid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_TagId <>'" + mycriteria.NePushTagid + "'";
            }
            if (mycriteria.NullPushTagid)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_TagId is null"; 
            }
            if (mycriteria.NotNullPushTagid)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_TagId is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushTitle))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Title like '%" + mycriteria.LikePushTitle + "%'";
            }
            if (mycriteria.InPushTitle.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushTitle)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_Title in (" + instr + ")";
            }
            if (mycriteria.NotPushTitle.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushTitle)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_Title not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushTitle.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushTitle)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_Title='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushTitle.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushTitle)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_Title like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushTitle))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_Title ='" + mycriteria.EqPushTitle + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushTitle))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_Title <>'" + mycriteria.NePushTitle + "'";
            }
            if (mycriteria.NullPushTitle)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Title is null"; 
            }
            if (mycriteria.NotNullPushTitle)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Title is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushBody))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Body like '%" + mycriteria.LikePushBody + "%'";
            }
            if (mycriteria.InPushBody.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushBody)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_Body in (" + instr + ")";
            }
            if (mycriteria.NotPushBody.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushBody)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_Body not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushBody.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushBody)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_Body='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushBody.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushBody)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_Body like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushBody))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_Body ='" + mycriteria.EqPushBody + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushBody))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_Body <>'" + mycriteria.NePushBody + "'";
            }
            if (mycriteria.NullPushBody)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Body is null"; 
            }
            if (mycriteria.NotNullPushBody)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_Body is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushIoslink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_IosLink like '%" + mycriteria.LikePushIoslink + "%'";
            }
            if (mycriteria.InPushIoslink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushIoslink)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_IosLink in (" + instr + ")";
            }
            if (mycriteria.NotPushIoslink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushIoslink)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_IosLink not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushIoslink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushIoslink)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_IosLink='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushIoslink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushIoslink)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_IosLink like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushIoslink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_IosLink ='" + mycriteria.EqPushIoslink + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushIoslink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_IosLink <>'" + mycriteria.NePushIoslink + "'";
            }
            if (mycriteria.NullPushIoslink)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_IosLink is null"; 
            }
            if (mycriteria.NotNullPushIoslink)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_IosLink is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushAndlink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_AndLink like '%" + mycriteria.LikePushAndlink + "%'";
            }
            if (mycriteria.InPushAndlink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushAndlink)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_AndLink in (" + instr + ")";
            }
            if (mycriteria.NotPushAndlink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushAndlink)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_AndLink not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushAndlink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushAndlink)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_AndLink='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushAndlink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushAndlink)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_AndLink like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushAndlink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_AndLink ='" + mycriteria.EqPushAndlink + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushAndlink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_AndLink <>'" + mycriteria.NePushAndlink + "'";
            }
            if (mycriteria.NullPushAndlink)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_AndLink is null"; 
            }
            if (mycriteria.NotNullPushAndlink)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_AndLink is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushWeblink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_WebLink like '%" + mycriteria.LikePushWeblink + "%'";
            }
            if (mycriteria.InPushWeblink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushWeblink)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_WebLink in (" + instr + ")";
            }
            if (mycriteria.NotPushWeblink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushWeblink)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_WebLink not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushWeblink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushWeblink)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_WebLink='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushWeblink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushWeblink)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_WebLink like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushWeblink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_WebLink ='" + mycriteria.EqPushWeblink + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushWeblink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_WebLink <>'" + mycriteria.NePushWeblink + "'";
            }
            if (mycriteria.NullPushWeblink)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_WebLink is null"; 
            }
            if (mycriteria.NotNullPushWeblink)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_WebLink is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikePushWechatlink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_WechatLink like '%" + mycriteria.LikePushWechatlink + "%'";
            }
            if (mycriteria.InPushWechatlink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InPushWechatlink)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Push_WechatLink in (" + instr + ")";
            }
            if (mycriteria.NotPushWechatlink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotPushWechatlink)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Push_WechatLink not in (" + instr + ")";
            }
            if (mycriteria.OrEqPushWechatlink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqPushWechatlink)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_WechatLink='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikePushWechatlink.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikePushWechatlink)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Push_WechatLink like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqPushWechatlink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_WechatLink ='" + mycriteria.EqPushWechatlink + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NePushWechatlink))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Push_WechatLink <>'" + mycriteria.NePushWechatlink + "'";
            }
            if (mycriteria.NullPushWechatlink)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_WechatLink is null"; 
            }
            if (mycriteria.NotNullPushWechatlink)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Push_WechatLink is not null";
            }
            if (mycriteria.InHaveSend.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InHaveSend)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Have_Send in (" + instr + ")";
            }
            if (mycriteria.NotHaveSend.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotHaveSend)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Have_Send not in (" + instr + ")";
            }
            if (mycriteria.OrEqHaveSend.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqHaveSend)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Have_Send="+str.ToString()+" or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.EqHaveSend!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Have_Send =" + mycriteria.EqHaveSend;
            }
            if (mycriteria.NeHaveSend!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Have_Send <>" + mycriteria.NeHaveSend;
            }
            if (mycriteria.LeHaveSend!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Have_Send <=" + mycriteria.LeHaveSend;
            }
            if (mycriteria.GeHaveSend!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Have_Send >=" + mycriteria.GeHaveSend;
            }
            if (mycriteria.LtHaveSend!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Have_Send <" + mycriteria.LtHaveSend;
            }
            if (mycriteria.GtHaveSend!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Have_Send >" + mycriteria.GtHaveSend;
            }
            if (mycriteria.NullHaveSend)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Have_Send is null"; 
            }
            if (mycriteria.NotNullHaveSend)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Have_Send is not null";
            }
            if (mycriteria.InIsSuccessed.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InIsSuccessed)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Is_Successed in (" + instr + ")";
            }
            if (mycriteria.NotIsSuccessed.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotIsSuccessed)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Is_Successed not in (" + instr + ")";
            }
            if (mycriteria.OrEqIsSuccessed.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqIsSuccessed)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Is_Successed="+str.ToString()+" or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.EqIsSuccessed!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Successed =" + mycriteria.EqIsSuccessed;
            }
            if (mycriteria.NeIsSuccessed!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Successed <>" + mycriteria.NeIsSuccessed;
            }
            if (mycriteria.LeIsSuccessed!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Successed <=" + mycriteria.LeIsSuccessed;
            }
            if (mycriteria.GeIsSuccessed!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Successed >=" + mycriteria.GeIsSuccessed;
            }
            if (mycriteria.LtIsSuccessed!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Successed <" + mycriteria.LtIsSuccessed;
            }
            if (mycriteria.GtIsSuccessed!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Successed >" + mycriteria.GtIsSuccessed;
            }
            if (mycriteria.NullIsSuccessed)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Is_Successed is null"; 
            }
            if (mycriteria.NotNullIsSuccessed)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Is_Successed is not null";
            }
            if (mycriteria.EqSendTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Send_Time =" + mycriteria.EqSendTime;
            }
            if (mycriteria.NeSendTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Send_Time <>" + mycriteria.NeSendTime;
            }
            if (mycriteria.LeSendTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Send_Time <='" + mycriteria.LeSendTime + "'";
            }
            if (mycriteria.GeSendTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Send_Time >='" + mycriteria.GeSendTime + "'";
            }
            if (mycriteria.LtSendTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Send_Time <'" + mycriteria.LtSendTime + "'";
            }
            if (mycriteria.GtSendTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Send_Time >'" + mycriteria.GtSendTime + "'";
            }
            if (mycriteria.NullSendTime)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Send_Time is null"; 
            }
            if (mycriteria.NotNullSendTime)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Send_Time is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeReturnCode))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Return_Code like '%" + mycriteria.LikeReturnCode + "%'";
            }
            if (mycriteria.InReturnCode.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InReturnCode)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Return_Code in (" + instr + ")";
            }
            if (mycriteria.NotReturnCode.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotReturnCode)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Return_Code not in (" + instr + ")";
            }
            if (mycriteria.OrEqReturnCode.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqReturnCode)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Return_Code='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeReturnCode.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeReturnCode)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Return_Code like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqReturnCode))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Return_Code ='" + mycriteria.EqReturnCode + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeReturnCode))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Return_Code <>'" + mycriteria.NeReturnCode + "'";
            }
            if (mycriteria.NullReturnCode)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Return_Code is null"; 
            }
            if (mycriteria.NotNullReturnCode)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Return_Code is not null";
            }
            if (mycriteria.InHaveread.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InHaveread)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " HaveRead in (" + instr + ")";
            }
            if (mycriteria.NotHaveread.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotHaveread)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "HaveRead not in (" + instr + ")";
            }
            if (mycriteria.OrEqHaveread.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqHaveread)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "HaveRead="+str.ToString()+" or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.EqHaveread!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "HaveRead =" + mycriteria.EqHaveread;
            }
            if (mycriteria.NeHaveread!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "HaveRead <>" + mycriteria.NeHaveread;
            }
            if (mycriteria.LeHaveread!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "HaveRead <=" + mycriteria.LeHaveread;
            }
            if (mycriteria.GeHaveread!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "HaveRead >=" + mycriteria.GeHaveread;
            }
            if (mycriteria.LtHaveread!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "HaveRead <" + mycriteria.LtHaveread;
            }
            if (mycriteria.GtHaveread!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "HaveRead >" + mycriteria.GtHaveread;
            }
            if (mycriteria.NullHaveread)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " HaveRead is null"; 
            }
            if (mycriteria.NotNullHaveread)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " HaveRead is not null";
            }
            if (mycriteria.InIsDeleted.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InIsDeleted)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Is_Deleted in (" + instr + ")";
            }
            if (mycriteria.NotIsDeleted.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotIsDeleted)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Is_Deleted not in (" + instr + ")";
            }
            if (mycriteria.OrEqIsDeleted.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqIsDeleted)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Is_Deleted="+str.ToString()+" or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.EqIsDeleted!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Deleted =" + mycriteria.EqIsDeleted;
            }
            if (mycriteria.NeIsDeleted!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Deleted <>" + mycriteria.NeIsDeleted;
            }
            if (mycriteria.LeIsDeleted!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Deleted <=" + mycriteria.LeIsDeleted;
            }
            if (mycriteria.GeIsDeleted!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Deleted >=" + mycriteria.GeIsDeleted;
            }
            if (mycriteria.LtIsDeleted!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Deleted <" + mycriteria.LtIsDeleted;
            }
            if (mycriteria.GtIsDeleted!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Is_Deleted >" + mycriteria.GtIsDeleted;
            }
            if (mycriteria.NullIsDeleted)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Is_Deleted is null"; 
            }
            if (mycriteria.NotNullIsDeleted)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Is_Deleted is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeCreateUser))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Create_User like '%" + mycriteria.LikeCreateUser + "%'";
            }
            if (mycriteria.InCreateUser.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InCreateUser)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Create_User in (" + instr + ")";
            }
            if (mycriteria.NotCreateUser.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotCreateUser)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Create_User not in (" + instr + ")";
            }
            if (mycriteria.OrEqCreateUser.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqCreateUser)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Create_User='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeCreateUser.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeCreateUser)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Create_User like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqCreateUser))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Create_User ='" + mycriteria.EqCreateUser + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeCreateUser))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Create_User <>'" + mycriteria.NeCreateUser + "'";
            }
            if (mycriteria.NullCreateUser)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Create_User is null"; 
            }
            if (mycriteria.NotNullCreateUser)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Create_User is not null";
            }
            if (mycriteria.EqCreateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Create_Time =" + mycriteria.EqCreateTime;
            }
            if (mycriteria.NeCreateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Create_Time <>" + mycriteria.NeCreateTime;
            }
            if (mycriteria.LeCreateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Create_Time <='" + mycriteria.LeCreateTime + "'";
            }
            if (mycriteria.GeCreateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Create_Time >='" + mycriteria.GeCreateTime + "'";
            }
            if (mycriteria.LtCreateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Create_Time <'" + mycriteria.LtCreateTime + "'";
            }
            if (mycriteria.GtCreateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Create_Time >'" + mycriteria.GtCreateTime + "'";
            }
            if (mycriteria.NullCreateTime)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Create_Time is null"; 
            }
            if (mycriteria.NotNullCreateTime)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Create_Time is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeUpdateUser))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Update_User like '%" + mycriteria.LikeUpdateUser + "%'";
            }
            if (mycriteria.InUpdateUser.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InUpdateUser)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Update_User in (" + instr + ")";
            }
            if (mycriteria.NotUpdateUser.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotUpdateUser)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Update_User not in (" + instr + ")";
            }
            if (mycriteria.OrEqUpdateUser.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqUpdateUser)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Update_User='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeUpdateUser.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeUpdateUser)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Update_User like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqUpdateUser))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Update_User ='" + mycriteria.EqUpdateUser + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeUpdateUser))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Update_User <>'" + mycriteria.NeUpdateUser + "'";
            }
            if (mycriteria.NullUpdateUser)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Update_User is null"; 
            }
            if (mycriteria.NotNullUpdateUser)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Update_User is not null";
            }
            if (mycriteria.EqUpdateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Update_Time =" + mycriteria.EqUpdateTime;
            }
            if (mycriteria.NeUpdateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Update_Time <>" + mycriteria.NeUpdateTime;
            }
            if (mycriteria.LeUpdateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Update_Time <='" + mycriteria.LeUpdateTime + "'";
            }
            if (mycriteria.GeUpdateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Update_Time >='" + mycriteria.GeUpdateTime + "'";
            }
            if (mycriteria.LtUpdateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Update_Time <" + mycriteria.LtUpdateTime;
            }
            if (mycriteria.GtUpdateTime!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Update_Time >" + mycriteria.GtUpdateTime;
            }
            if (mycriteria.NullUpdateTime)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Update_Time is null"; 
            }
            if (mycriteria.NotNullUpdateTime)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Update_Time is not null";
            }
            if (mycriteria.EqTimestamp!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Timestamp =" + mycriteria.EqTimestamp;
            }
            if (mycriteria.NeTimestamp!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Timestamp <>" + mycriteria.NeTimestamp;
            }
            if (mycriteria.LeTimestamp!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Timestamp <=" + mycriteria.LeTimestamp;
            }
            if (mycriteria.GeTimestamp!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Timestamp >=" + mycriteria.GeTimestamp;
            }
            if (mycriteria.LtTimestamp!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Timestamp <" + mycriteria.LtTimestamp;
            }
            if (mycriteria.GtTimestamp!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Timestamp >" + mycriteria.GtTimestamp;
            }
            if (mycriteria.NullTimestamp)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Timestamp is null"; 
            }
            if (mycriteria.NotNullTimestamp)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Timestamp is not null";
            }
            
            return where;
        }
        
        #endregion
        
        
        
        
    }
}
