Beispiel #1
0
        private SingleClause BuildSingleClause(KeyValuePair <string, string> kv)
        {
            SingleClause sc = new SingleClause();

            sc.PropertyName = kv.Key;
            sc.Value        = kv.Value;

            switch (kv.Key)
            {
            case "appCode":
            case "mail":
            case "fax":
            case "telefono":
            case "codiceCanale":
            case "codiceBackend":
            case "categoria":
                sc.Operator = CriteriaOperator.Equal;
                break;

            case "contactRef":
                sc.Operator = CriteriaOperator.StartsWith;
                break;

            case "descrBackend":
            case "descrBackendPlus":
                sc.Operator = CriteriaOperator.Like;
                break;
            }
            return(sc);
        }
Beispiel #2
0
            /// <summary>
            ///     Adds an <see cref="SingleClause" /> element for a join of the form <paramref name="leftSlot" /> =
            ///     <paramref
            ///         name="rightSlot" />
            ///     .
            /// </summary>
            internal void Add(
                QualifiedSlot leftSlot, MemberPath leftSlotOutputMember, QualifiedSlot rightSlot, MemberPath rightSlotOutputMember)
            {
                var singleClause = new SingleClause(leftSlot, leftSlotOutputMember, rightSlot, rightSlotOutputMember);

                m_singleClauses.Add(singleClause);
            }
Beispiel #3
0
        private SingleClause NuildNotNullClause(KeyValuePair <string, string> kv)
        {
            SingleClause sc = new SingleClause();

            sc.PropertyName = kv.Key;
            sc.Operator     = CriteriaOperator.IsNotNull;
            return(sc);
        }
Beispiel #4
0
        private SingleClause NuildNotNullClause(PropertyInfo pi)
        {
            SingleClause sc = new SingleClause();

            object[] pa = pi.GetCustomAttributes(typeof(DatabaseFieldAttribute), true);
            if (pa != null && pa.Length == 1)
            {
                DatabaseFieldAttribute dba = (DatabaseFieldAttribute)(pa[0]);
                if (dba != null && dba.FieldName.Length > 0)
                {
                    sc.PropertyName = dba.FieldName;
                }
            }
            sc.Operator = CriteriaOperator.IsNotNull;
            return(sc);
        }
Beispiel #5
0
        private SingleClause BuildSingleClause(ContactsApplicationMapping c, PropertyInfo pi)
        {
            SingleClause sc = new SingleClause();

            object[] pa = pi.GetCustomAttributes(typeof(DatabaseFieldAttribute), true);
            if (pa != null && pa.Length == 1)
            {
                DatabaseFieldAttribute dba = (DatabaseFieldAttribute)(pa[0]);
                if (dba != null && dba.FieldName.Length > 0)
                {
                    sc.PropertyName = dba.FieldName;
                }
            }

            sc.Value = pi.GetValue(c, null);

            switch (sc.PropertyName)
            {
            case "APP_CODE":
            case "MAIL":
            case "FAX":
            case "TELEFONO":
            case "CODICE":
            case "BACKEND_CODE":
            case "CATEGORY":
            case "COM_CODE":
            case "SOTTOTITOLO_ACTIVE":
            case "TITOLO_ACTIVE":
                sc.Operator = CriteriaOperator.Equal;
                break;

            case "CONTACT_REF":
                sc.Operator = CriteriaOperator.StartsWith;
                break;

            case "BACKEND_DESCR":
            case "DESCR_PLUS":
                sc.Operator = CriteriaOperator.Like;
                break;
            }

            return(sc);
        }
Beispiel #6
0
        private string TranslateIClause(IClause clause, DbCommand oCmd, ref int k)
        {
            String cmdText = "";

            if (clause is SingleClause)
            {
                SingleClause sc = clause as SingleClause;

                if (sc.Operator == CriteriaOperator.IsNull || sc.Operator == CriteriaOperator.IsNotNull)
                {
                    cmdText += String.Format("({0} {1})", sc.PropertyName, DaoSQLServerDBHelper.TranslateOperator(sc.Operator));
                }
                else
                {
                    string par = String.Format("p{0}", k++);
                    cmdText += String.Format("({0} {1} :{2})", sc.PropertyName, DaoSQLServerDBHelper.TranslateOperator(sc.Operator), par);
                    try
                    {
                        ObjectParameter p = new ObjectParameter(par, ((SingleClause)clause).Value.ToString());
                        //oCmd.Parameters.Add(par, ((SingleClause)clause).Value.ToString());
                    }
                    catch
                    {
                    }
                }
            }
            else if (clause is CombinedClause)
            {
                cmdText += "(";
                CombinedClause cc = clause as CombinedClause;
                for (int j = 0; j < cc.SubClauses.Count() - 1; j++)
                {
                    cmdText += String.Format("{0} {1} ", TranslateIClause(cc.SubClauses.ElementAt(j), oCmd, ref k),
                                             cc.ClauseType.ToString().ToUpper());
                }
                cmdText += String.Format("{0})", TranslateIClause(cc.SubClauses.Last(), oCmd, ref k));
            }
            return(cmdText);
        }
 /// <summary>
 ///     Adds an <see cref="SingleClause" /> element for a join of the form <paramref name="leftSlot" /> =
 ///     <paramref
 ///         name="rightSlot" />
 ///     .
 /// </summary>
 internal void Add(
     QualifiedSlot leftSlot, MemberPath leftSlotOutputMember, QualifiedSlot rightSlot, MemberPath rightSlotOutputMember)
 {
     var singleClause = new SingleClause(leftSlot, leftSlotOutputMember, rightSlot, rightSlotOutputMember);
     m_singleClauses.Add(singleClause);
 }