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 ProjectInfoDaoAchieve
    {
        
        
        
        
        #region Dao
        public int Save(ProjectInfo entity)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("Insert into project_info values (@Id,@ProjectName,@ProjectType,@InternalPrincipal,@InternalPrincipalMobile,@Db_ConnectId,@Object_Sql,@Child_ProjectInfo,@User_Sql,@Create_User,@Create_Time,@Update_User,@Update_Time,@Is_Deleted,@Timestamp)",
                                   entity);
                return result;
            }
        }
        
        public int Save(List<ProjectInfo> entityList)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("Insert into project_info values (@Id,@ProjectName,@ProjectType,@InternalPrincipal,@InternalPrincipalMobile,@Db_ConnectId,@Object_Sql,@Child_ProjectInfo,@User_Sql,@Create_User,@Create_Time,@Update_User,@Update_Time,@Is_Deleted,@Timestamp)",
                                   entityList);
                return result;
            }
        }
        
        
        public int Delete(string id)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("delete from project_info where Id=@id",
                                   new { id = id });
                return result;
            }
        }
        
        public int Update(ProjectInfo entity)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("update project_info set ProjectName=@ProjectName,ProjectType=@ProjectType,InternalPrincipal=@InternalPrincipal,InternalPrincipalMobile=@InternalPrincipalMobile,Db_ConnectId=@Db_ConnectId,Object_Sql=@Object_Sql,Child_ProjectInfo=@Child_ProjectInfo,User_Sql=@User_Sql,Create_User=@Create_User,Create_Time=@Create_Time,Update_User=@Update_User,Update_Time=@Update_Time,Is_Deleted=@Is_Deleted,Timestamp=@Timestamp where Id=@id",
                                   entity);
                return result;
            }
        }
        
        public int Update(List<ProjectInfo> entityList)
        {
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var result = connection.Execute("update project_info set ProjectName=@ProjectName,ProjectType=@ProjectType,InternalPrincipal=@InternalPrincipal,InternalPrincipalMobile=@InternalPrincipalMobile,Db_ConnectId=@Db_ConnectId,Object_Sql=@Object_Sql,Child_ProjectInfo=@Child_ProjectInfo,User_Sql=@User_Sql,Create_User=@Create_User,Create_Time=@Create_Time,Update_User=@Update_User,Update_Time=@Update_Time,Is_Deleted=@Is_Deleted,Timestamp=@Timestamp where Id=@id",
                                   entityList);
                return result;
            }
        }
        
        public int SaveOrUpdate(IList<ProjectInfo> entityList)
        {
            if (entityList == null || entityList.Count == 0)
                return 0;
            List<ProjectInfo> saveList = new List<ProjectInfo>();
            List<ProjectInfo> updateList = new List<ProjectInfo>();
            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 project_info set ProjectName=@ProjectName,ProjectType=@ProjectType,InternalPrincipal=@InternalPrincipal,InternalPrincipalMobile=@InternalPrincipalMobile,Db_ConnectId=@Db_ConnectId,Object_Sql=@Object_Sql,Child_ProjectInfo=@Child_ProjectInfo,User_Sql=@User_Sql,Create_User=@Create_User,Create_Time=@Create_Time,Update_User=@Update_User,Update_Time=@Update_Time,Is_Deleted=@Is_Deleted,Timestamp=@Timestamp where Id=@id",
                                       updateList, transaction, null, null);
                    }
                    if (saveList.Count > 0)
                    {
                        save = connection.Execute("Insert into project_info values (@Id,@ProjectName,@ProjectType,@InternalPrincipal,@InternalPrincipalMobile,@Db_ConnectId,@Object_Sql,@Child_ProjectInfo,@User_Sql,@Create_User,@Create_Time,@Update_User,@Update_Time,@Is_Deleted,@Timestamp)",
                                       saveList, transaction, null, null);
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new Exception(ex.Message);
                }
                return save + update;
            }
        }
        
        public int SaveOrUpdateWithTran(IList<ProjectInfo> entityList, IDbConnection connection, IDbTransaction transaction)
        {
            if (entityList == null || entityList.Count == 0)
                return 0;
            List<ProjectInfo> saveList = new List<ProjectInfo>();
            List<ProjectInfo> updateList = new List<ProjectInfo>();
            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 project_info set ProjectName=@ProjectName,ProjectType=@ProjectType,InternalPrincipal=@InternalPrincipal,InternalPrincipalMobile=@InternalPrincipalMobile,Db_ConnectId=@Db_ConnectId,Object_Sql=@Object_Sql,Child_ProjectInfo=@Child_ProjectInfo,User_Sql=@User_Sql,Create_User=@Create_User,Create_Time=@Create_Time,Update_User=@Update_User,Update_Time=@Update_Time,Is_Deleted=@Is_Deleted,Timestamp=@Timestamp where Id=@id",
                               updateList, transaction, null, null);
            }
            if (saveList.Count > 0)
            {
                save = connection.Execute("Insert into project_info values (@Id,@ProjectName,@ProjectType,@InternalPrincipal,@InternalPrincipalMobile,@Db_ConnectId,@Object_Sql,@Child_ProjectInfo,@User_Sql,@Create_User,@Create_Time,@Update_User,@Update_Time,@Is_Deleted,@Timestamp)",
                               saveList, transaction, null, null);
            }
            return save + update;
        }
        
        public ProjectInfo Get(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            using(IDbConnection connection = new MySqlConnection(PushPlatformContext.connString))
            {
                var query = connection.Query<ProjectInfo>("select * from project_info where Id=@id", new { id = id });
                if (query.Count() > 0)
                    return query.FirstOrDefault();
                return null;
            }
        }
        
        public int GetCount(PushPlatform.Data.Criteria.CriteriaProjectInfo 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 project_info " + mycriteria.Where, mycriteria.WhereValue).FirstOrDefault();
                    }
                    else
                    {
                        return connection.Query<int>("select count(1) from project_info " + mycriteria.Where).FirstOrDefault();
                    }
                }
                else
                {
                    return connection.Query<int>("select count(1) from project_info " + CreatAutoQuery(mycriteria)).FirstOrDefault(); 
                }
            }
        }
        
        public List<ProjectInfo> Fetch(PushPlatform.Data.Criteria.CriteriaProjectInfo mycriteria)
        {
            if(mycriteria.UsePage && (mycriteria.PageIndex <= 0 || mycriteria.PageSize < 1))
            {
                mycriteria.PageTotal = 0;
                return new List<ProjectInfo>();
            }
            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 project_info " + mycriteria.Where + orderby, mycriteria.WhereValue).FirstOrDefault();
                            var query = connection.Query<ProjectInfo>("select * from project_info " + mycriteria.Where + orderby + " LIMIT " + pageStart.ToString() + "," + mycriteria.PageSize, mycriteria.WhereValue);
                            return query.ToList();
                        }
                        else
                        {
                            mycriteria.PageTotal = connection.Query<int>("select count(1) from project_info " + mycriteria.Where + orderby).FirstOrDefault();
                            var query = connection.Query<ProjectInfo>("select * from project_info " + mycriteria.Where + orderby + " LIMIT " + pageStart.ToString() + "," + mycriteria.PageSize);
                            return query.ToList();
                        }
                    }
                    else
                    {
                        if (mycriteria.WhereValue != null)
                        {
                            var query = connection.Query<ProjectInfo>("select * from project_info " + mycriteria.Where + orderby, mycriteria.WhereValue);
                            return query.ToList();
                        }
                        else
                        {
                            var query = connection.Query<ProjectInfo>("select * from project_info " + mycriteria.Where + orderby);
                            return query.ToList();
                        }
                    }
                }
                else
                {
                    if (mycriteria.UsePage)
                    {
                        string whereStr=CreatAutoQuery(mycriteria);
                        mycriteria.PageTotal = connection.Query<int>("select count(1) from project_info " + whereStr).FirstOrDefault();
                        string queryStr = "select * from project_info ";
                        queryStr += whereStr + orderby;
                        queryStr += " LIMIT " + pageStart.ToString() + "," + mycriteria.PageSize;
                        var query = connection.Query<ProjectInfo>(queryStr);
                        return query.ToList();
                    }
                    else
                    {
                        string queryStr = "select * from project_info ";
                        queryStr += CreatAutoQuery(mycriteria) + orderby;
                        var query = connection.Query<ProjectInfo>(queryStr);
                        return query.ToList();
                    }  
                }
            }
        }
        #endregion
        
        #region method
        private string CreatAutoQuery(Criteria.CriteriaProjectInfo 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.LikeProjectname))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " ProjectName like '%" + mycriteria.LikeProjectname + "%'";
            }
            if (mycriteria.InProjectname.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InProjectname)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " ProjectName in (" + instr + ")";
            }
            if (mycriteria.NotProjectname.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotProjectname)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "ProjectName not in (" + instr + ")";
            }
            if (mycriteria.OrEqProjectname.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqProjectname)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "ProjectName='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeProjectname.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeProjectname)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "ProjectName like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqProjectname))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "ProjectName ='" + mycriteria.EqProjectname + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeProjectname))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "ProjectName <>'" + mycriteria.NeProjectname + "'";
            }
            if (mycriteria.NullProjectname)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " ProjectName is null"; 
            }
            if (mycriteria.NotNullProjectname)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " ProjectName is not null";
            }
            if (mycriteria.InProjecttype.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InProjecttype)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " ProjectType in (" + instr + ")";
            }
            if (mycriteria.NotProjecttype.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotProjecttype)
                {
                    instr += str.ToString()+",";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "ProjectType not in (" + instr + ")";
            }
            if (mycriteria.OrEqProjecttype.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqProjecttype)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "ProjectType="+str.ToString()+" or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.EqProjecttype!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "ProjectType =" + mycriteria.EqProjecttype;
            }
            if (mycriteria.NeProjecttype!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "ProjectType <>" + mycriteria.NeProjecttype;
            }
            if (mycriteria.LeProjecttype!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "ProjectType <=" + mycriteria.LeProjecttype;
            }
            if (mycriteria.GeProjecttype!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "ProjectType >=" + mycriteria.GeProjecttype;
            }
            if (mycriteria.LtProjecttype!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "ProjectType <" + mycriteria.LtProjecttype;
            }
            if (mycriteria.GtProjecttype!=null)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "ProjectType >" + mycriteria.GtProjecttype;
            }
            if (mycriteria.NullProjecttype)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " ProjectType is null"; 
            }
            if (mycriteria.NotNullProjecttype)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " ProjectType is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeInternalprincipal))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " InternalPrincipal like '%" + mycriteria.LikeInternalprincipal + "%'";
            }
            if (mycriteria.InInternalprincipal.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InInternalprincipal)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " InternalPrincipal in (" + instr + ")";
            }
            if (mycriteria.NotInternalprincipal.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotInternalprincipal)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "InternalPrincipal not in (" + instr + ")";
            }
            if (mycriteria.OrEqInternalprincipal.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqInternalprincipal)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "InternalPrincipal='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeInternalprincipal.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeInternalprincipal)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "InternalPrincipal like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqInternalprincipal))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "InternalPrincipal ='" + mycriteria.EqInternalprincipal + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeInternalprincipal))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "InternalPrincipal <>'" + mycriteria.NeInternalprincipal + "'";
            }
            if (mycriteria.NullInternalprincipal)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " InternalPrincipal is null"; 
            }
            if (mycriteria.NotNullInternalprincipal)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " InternalPrincipal is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeInternalprincipalmobile))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " InternalPrincipalMobile like '%" + mycriteria.LikeInternalprincipalmobile + "%'";
            }
            if (mycriteria.InInternalprincipalmobile.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InInternalprincipalmobile)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " InternalPrincipalMobile in (" + instr + ")";
            }
            if (mycriteria.NotInternalprincipalmobile.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotInternalprincipalmobile)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "InternalPrincipalMobile not in (" + instr + ")";
            }
            if (mycriteria.OrEqInternalprincipalmobile.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqInternalprincipalmobile)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "InternalPrincipalMobile='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeInternalprincipalmobile.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeInternalprincipalmobile)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "InternalPrincipalMobile like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqInternalprincipalmobile))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "InternalPrincipalMobile ='" + mycriteria.EqInternalprincipalmobile + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeInternalprincipalmobile))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "InternalPrincipalMobile <>'" + mycriteria.NeInternalprincipalmobile + "'";
            }
            if (mycriteria.NullInternalprincipalmobile)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " InternalPrincipalMobile is null"; 
            }
            if (mycriteria.NotNullInternalprincipalmobile)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " InternalPrincipalMobile is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeDbConnectid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Db_ConnectId like '%" + mycriteria.LikeDbConnectid + "%'";
            }
            if (mycriteria.InDbConnectid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InDbConnectid)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Db_ConnectId in (" + instr + ")";
            }
            if (mycriteria.NotDbConnectid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotDbConnectid)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Db_ConnectId not in (" + instr + ")";
            }
            if (mycriteria.OrEqDbConnectid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqDbConnectid)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Db_ConnectId='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeDbConnectid.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeDbConnectid)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Db_ConnectId like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqDbConnectid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Db_ConnectId ='" + mycriteria.EqDbConnectid + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeDbConnectid))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Db_ConnectId <>'" + mycriteria.NeDbConnectid + "'";
            }
            if (mycriteria.NullDbConnectid)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Db_ConnectId is null"; 
            }
            if (mycriteria.NotNullDbConnectid)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Db_ConnectId is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeObjectSql))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Object_Sql like '%" + mycriteria.LikeObjectSql + "%'";
            }
            if (mycriteria.InObjectSql.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InObjectSql)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Object_Sql in (" + instr + ")";
            }
            if (mycriteria.NotObjectSql.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotObjectSql)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Object_Sql not in (" + instr + ")";
            }
            if (mycriteria.OrEqObjectSql.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqObjectSql)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Object_Sql='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeObjectSql.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeObjectSql)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Object_Sql like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqObjectSql))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Object_Sql ='" + mycriteria.EqObjectSql + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeObjectSql))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Object_Sql <>'" + mycriteria.NeObjectSql + "'";
            }
            if (mycriteria.NullObjectSql)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Object_Sql is null"; 
            }
            if (mycriteria.NotNullObjectSql)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Object_Sql is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeChildProjectinfo))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Child_ProjectInfo like '%" + mycriteria.LikeChildProjectinfo + "%'";
            }
            if (mycriteria.InChildProjectinfo.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InChildProjectinfo)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " Child_ProjectInfo in (" + instr + ")";
            }
            if (mycriteria.NotChildProjectinfo.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotChildProjectinfo)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "Child_ProjectInfo not in (" + instr + ")";
            }
            if (mycriteria.OrEqChildProjectinfo.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqChildProjectinfo)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Child_ProjectInfo='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeChildProjectinfo.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeChildProjectinfo)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "Child_ProjectInfo like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqChildProjectinfo))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Child_ProjectInfo ='" + mycriteria.EqChildProjectinfo + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeChildProjectinfo))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "Child_ProjectInfo <>'" + mycriteria.NeChildProjectinfo + "'";
            }
            if (mycriteria.NullChildProjectinfo)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Child_ProjectInfo is null"; 
            }
            if (mycriteria.NotNullChildProjectinfo)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " Child_ProjectInfo is not null";
            }
            if (!string.IsNullOrEmpty(mycriteria.LikeUserSql))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " User_Sql like '%" + mycriteria.LikeUserSql + "%'";
            }
            if (mycriteria.InUserSql.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.InUserSql)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += " User_Sql in (" + instr + ")";
            }
            if (mycriteria.NotUserSql.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.NotUserSql)
                {
                    instr += "'"+str+"',";
                }
                instr = instr.Substring(0,instr.Length-1);
                where += "User_Sql not in (" + instr + ")";
            }
            if (mycriteria.OrEqUserSql.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrEqUserSql)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "User_Sql='"+str+"' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (mycriteria.OrLikeUserSql.Count>0)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                string instr = "";
                foreach(var str in mycriteria.OrLikeUserSql)
                {
                    if(instr=="")
                    {instr="(";}
                    instr += "User_Sql like '%"+str+"%' or ";
                }
                instr = instr.Substring(0,instr.Length-4);
                instr+=")";
                where += instr;
            }
            if (!string.IsNullOrEmpty(mycriteria.EqUserSql))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "User_Sql ='" + mycriteria.EqUserSql + "'";
            }
            if (!string.IsNullOrEmpty(mycriteria.NeUserSql))
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += "User_Sql <>'" + mycriteria.NeUserSql + "'";
            }
            if (mycriteria.NullUserSql)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " User_Sql is null"; 
            }
            if (mycriteria.NotNullUserSql)
            {
                if(where==""){ where += "where "; } else if(mycriteria.UseOr) {where += " or ";} else { where += " and "; }
                where += " User_Sql 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.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 (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
        
        
        
        
    }
}
