Beispiel #1
0
 public override string Query()
 {
     if (Value == null)
     {
         return("NULL");
     }
     return(SqlCSharp.SqlValue(Value, SqlType, InList));
 }
Beispiel #2
0
        private string UpdateQuery(IEnumerable <PropertyProxy> _changes, ClassProxy _classAndProxy)
        {
            List <FieldValue> _fieldsValues = FieldsValues(_changes, _classAndProxy);

            return("UPDATE " + _classAndProxy.TypeName.ToLower() +
                   " SET " + FieldsEqualValues(_fieldsValues, _classAndProxy) +
                   " WHERE " + _classAndProxy.TypeName.ToLower() + ".id = " +
                   SqlCSharp.SqlValue(_classAndProxy.Entity, TypeHelper.Property(_classAndProxy.Entity.GetType(), "ID")) +
                   ";");
        }
Beispiel #3
0
        private void BuildQuery()
        {
            if (Path != null)
            {
                __query = MemberExpression(Path);
            }

            foreach (object _element in __expression)
            {
                if (_element is DBMemberExpressionComparison other)
                {
                    if (Path != null && Path.Count > 1)
                    {
                        if (__lastOperatorLogicPos != -1)
                        {
                            if (other.Path != null)
                            {
                                int _parenthesis = Path.Count - Path.CommonMembersWith(other.Path) - 1;

                                if (_parenthesis > 0) // dans le cas ou Path et other.Path expriment le mêmes objets, _parenthesis == -1
                                {
                                    __query              = __query.Insert(__lastOperatorLogicPos, new string(')', _parenthesis));
                                    __openedParenthesis -= _parenthesis;
                                }
                            }
                            __lastOperatorLogicPos = -1;
                        }
                        other.Path = RemoveCommonMembers(other.Path);
                    }
                    __query += other.Query();
                }
                else
                if (_element is MemberPath _path)
                {
                    __query += _path.LastPropertyName.ToLower() + " ";
                }
                else
                if (_element is string s)
                {
                    if (DBExpressionBuilder.IsOperatorLogic(ref s))
                    {
                        __lastOperatorLogicPos = __query.Length;
                        __query += s + " ";
                    }
                    else
                    if (DBExpressionBuilder.IsSymbol(ref s))
                    {
                        __query += s + " ";
                        if (s == "(")
                        {
                            ++__openedParenthesis;
                        }
                        else
                        if (s == ")")
                        {
                            --__openedParenthesis;
                        }
                    }
                    else
                    {
                        __query += SqlCSharp.SqlValue(_element) + " ";
                    }
                }

                else
                {
                    __query += SqlCSharp.SqlValue(_element) + " ";
                }
            }
            __query += new string(')', __openedParenthesis);
        }