Exemplo n.º 1
0
        public virtual EntityMap <T> AddParameter(DataMemberMap DataMemberMap)
        {
            DbParameter parameter     = this._command.CreateParameter();
            string      ParameterName = string.Format("@{0}", DataMemberMap.ParameterName);

            parameter.ParameterName = ParameterName;
            parameter.Value         = DataMemberMap.DataValue;
            this._command.Parameters.Add(parameter);
            return(this);
        }
Exemplo n.º 2
0
        public static void AppendMember(this List <IDataMemberMap> DataMemberMapSet, MemberDataMap MemberDataMap, EntityMemberMap EntityMemberMap)
        {
            DataMemberMap DataMemberMap = new DataMemberMap()
            {
                ParameterName = MemberDataMap.DataFieldName + Guid.NewGuid().ToString("N"),
                DataFieldName = MemberDataMap.DataFieldName,
                DataValue     = EntityMemberMap.MemberValue,
                Operator      = EntityMemberMap.Operator,
                LogicSymbol   = EntityMemberMap.LogicSymbol
            };

            DataMemberMapSet.Add(DataMemberMap);
        }
Exemplo n.º 3
0
        protected string ParseWhereByParam(IDataMemberMap tmap)
        {
            if (tmap is DataMemberMap)
            {
                DataMemberMap map         = tmap as DataMemberMap;
                string        logicSymbol = "";
                switch (map.LogicSymbol)
                {
                case EntityRequest.LogicSymbol.And:
                    logicSymbol = " AND ";
                    break;

                case EntityRequest.LogicSymbol.Or:
                    logicSymbol = " OR ";
                    break;
                }
                switch (map.Operator)
                {
                case EntityRequest.Operator.Than:
                    return(string.Format(" {1} {0}>@{2} ", map.DataFieldName, logicSymbol, map.ParameterName));

                case EntityRequest.Operator.Lessthan:
                    return(string.Format(" {1} {0}<@{2} ", map.DataFieldName, logicSymbol, map.ParameterName));

                case EntityRequest.Operator.LessthanAndEqual:
                    return(string.Format(" {1} {0}<=@{2} ", map.DataFieldName, logicSymbol, map.ParameterName));

                case EntityRequest.Operator.ThanAndEqual:
                    return(string.Format(" {1} {0}>=@{2} ", map.DataFieldName, logicSymbol, map.ParameterName));

                case EntityRequest.Operator.StartWith:
                    return(string.Format(" {1} PATINDEX(@{2}+'%',{0})>0 ", map.DataFieldName, logicSymbol, map.ParameterName));

                case EntityRequest.Operator.EndWith:
                    return(string.Format(" {1} PATINDEX('%'+@{2},{0})>0 ", map.DataFieldName, logicSymbol, map.ParameterName));

                case EntityRequest.Operator.Contain:
                    return(string.Format(" {1} PATINDEX('%'+@{2}+'%',{0})>0 ", map.DataFieldName, logicSymbol, map.ParameterName));

                case EntityRequest.Operator.NotEqual:
                    return(string.Format(" {1} NOT {0}=@{2} ", map.DataFieldName, logicSymbol, map.ParameterName));

                case  EntityRequest.Operator.BitFlagContain:
                    return(string.Format(" {1} {0}&@{2}=@{2} ", map.DataFieldName, logicSymbol, map.ParameterName));

                case EntityRequest.Operator.BitFlagNotContain:
                    return(string.Format(" {1} {0}&@{2}!=@{2} ", map.DataFieldName, logicSymbol, map.ParameterName));

                default:
                    return(string.Format(" {1} {0}=@{2} ", map.DataFieldName, logicSymbol, map.ParameterName));
                }
            }
            else if (tmap is LogicLinkMap)
            {
                LogicLinkMap lmap        = tmap as LogicLinkMap;
                string       logicSymbol = "";
                switch (lmap.LogicSymbol)
                {
                case EntityRequest.LogicSymbol.And:
                    logicSymbol = " AND ";
                    break;

                case EntityRequest.LogicSymbol.Or:
                    logicSymbol = " OR ";
                    break;
                }
                switch (lmap.LogicLink)
                {
                case EntityRequest.LogicLink.LeftBracket:
                    return(logicSymbol + " ( 1=1");

                case EntityRequest.LogicLink.RightBracket:
                    return(")");
                }
            }
            return("");
        }