public virtual MarshalQuery FromQuery(IQuery query)
        {
            MarshalQuery mq = new MarshalQuery();

            if (query is NPathQuery)
            {
                mq.QueryType = "NPathQuery";
            }
            if (query is SqlQuery)
            {
                mq.QueryType = "SqlQuery";
            }
            IClassMap classMap = Context.DomainMap.MustGetClassMap(query.PrimaryType);

            mq.PrimitiveType = classMap.GetName();
            mq.QueryString   = query.Query.ToString();
            foreach (IQueryParameter p in query.Parameters)
            {
                MarshalParameter mp = new MarshalParameter();
                mp.DbType = p.DbType;
                mp.Name   = p.Name;
                mp.Value  = FromParameterValue(p);
                mq.Parameters.Add(mp);
            }
            return(mq);
        }
        public virtual IQuery ToQuery(MarshalQuery marshalQuery)
        {
            IQuery    query    = null;
            IContext  ctx      = this.Context;
            IClassMap classMap = ctx.DomainMap.MustGetClassMap(marshalQuery.PrimitiveType);
            Type      realType = ctx.AssemblyManager.MustGetTypeFromClassMap(classMap);

            if (marshalQuery.QueryType == "NPathQuery")
            {
                query = new NPathQuery(marshalQuery.QueryString, realType, this.Context);
            }
            if (marshalQuery.QueryType == "SqlQuery")
            {
                query = new SqlQuery(marshalQuery.QueryString, realType, this.Context);
            }
            query.Query = marshalQuery.QueryString;
            foreach (MarshalParameter mp in marshalQuery.Parameters)
            {
                object          value = ToParameterValue(mp);
                IQueryParameter param = new QueryParameter(mp.Name, mp.DbType, value);
                query.Parameters.Add(param);
            }
            return(query);
        }
 public virtual IQuery ToQuery(MarshalQuery marshalQuery)
 {
     IQuery query = null;
     IContext ctx = this.Context;
     IClassMap classMap = ctx.DomainMap.MustGetClassMap(marshalQuery.PrimitiveType);
     Type realType = ctx.AssemblyManager.MustGetTypeFromClassMap(classMap);
     if (marshalQuery.QueryType == "NPathQuery")
         query = new NPathQuery(marshalQuery.QueryString, realType, this.Context);
     if (marshalQuery.QueryType == "SqlQuery")
         query = new SqlQuery(marshalQuery.QueryString, realType, this.Context);
     query.Query = marshalQuery.QueryString;
     foreach (MarshalParameter mp in marshalQuery.Parameters)
     {
         object value = ToParameterValue(mp);
         IQueryParameter param = new QueryParameter(mp.Name, mp.DbType, value);
         query.Parameters.Add(param);
     }
     return query;
 }
 public virtual MarshalQuery FromQuery(IQuery query)
 {
     MarshalQuery mq = new MarshalQuery() ;
     if (query is NPathQuery)
         mq.QueryType = "NPathQuery";
     if (query is SqlQuery)
         mq.QueryType = "SqlQuery";
     IClassMap classMap = Context.DomainMap.MustGetClassMap(query.PrimaryType);
     mq.PrimitiveType = classMap.GetName() ;
     mq.QueryString = query.Query.ToString() ;
     foreach (IQueryParameter p in query.Parameters)
     {
         MarshalParameter mp = new MarshalParameter() ;
         mp.DbType = p.DbType;
         mp.Name = p.Name ;
         mp.Value = FromParameterValue(p) ;
         mq.Parameters.Add(mp);
     }
     return mq;
 }