Beispiel #1
0
        public String ToSqlStringForward(String target)
        {
            AttributeWorker w = AttributeWorker.GetInstance(target);

            StringBuilder tmp = new StringBuilder();

            bool start = true;

            foreach (String key in _virtualKeyValues.Keys)
            {
                if (!start)
                {
                    tmp.Append(" AND ");
                }
                start = false;
                Object val = _virtualKeyValues[key];

                if (val == null)
                {
                    throw new InvalidOperationException("The key is not initialized");
                }

                String    translatedKey = _keyTranslation[key];
                FieldInfo joinField     = _virtualJoinKeyFields[translatedKey];
                String    column        = w.GetColumnMapping(joinField);
                tmp.Append(column).Append("=").Append(SqlUtil.SqlConvert(val));
            }

            return(tmp.ToString());
        }
Beispiel #2
0
        private QueryGenerator ToSqlRestrictionForward(String target, Serializer.Serializer ser)
        {
            AttributeWorker w = AttributeWorker.GetInstance(target);

            QueryGenerator gen = new QueryGenerator();

            gen.AddQueryComponent(new SqlStringComponent(" WHERE "));

            bool start = true;

            foreach (String key in _virtualDefKeyFields.Keys)
            {
                if (!start)
                {
                    gen.AddQueryComponent(new SqlStringComponent(" AND "));
                }
                else
                {
                    gen.AddQueryComponent(new SqlStringComponent("("));
                }
                start = false;

                String    translatedKey = _keyTranslation[key];
                FieldInfo joinField     = _virtualJoinKeyFields[translatedKey];
                String    joinMapping   = w.GetColumnMapping(joinField);

                FieldInfo defField   = _virtualDefKeyFields[key];
                String    defMapping = w.GetColumnMapping(defField);

                StringBuilder tmp = new StringBuilder();

                tmp.Append(defMapping).Append(" IN (SELECT ").Append(joinMapping).Append(" FROM ");
                tmp.Append(w.GetTableMapping(TargetType, ser.Praefix));
                gen.AddQueryComponent(new SqlStringComponent(tmp));
                gen.AddQueryComponent(new PlaceHolderComponent());
                gen.AddQueryComponent(new SqlStringComponent(")"));
            }

            gen.AddQueryComponent(new SqlStringComponent(")"));
            return(gen);

            //ret.Append(")");
            //return ret.ToString();
        }
Beispiel #3
0
        public String ToSqlStringBackward(String target)
        {
            AttributeWorker w = AttributeWorker.GetInstance(target);

            StringBuilder tmp = new StringBuilder();

            bool start = true;

            foreach (String key in _virtualKeyValues.Keys)
            {
                if (!start)
                {
                    tmp.Append(" AND ");
                }
                start = false;
                Object    val      = _virtualKeyValues[key];
                FieldInfo defField = _virtualDefKeyFields[key];
                String    column   = w.GetColumnMapping(defField);
                tmp.Append(column).Append("=").Append(SqlUtil.SqlConvert(val));
            }

            return(tmp.ToString());
        }