示例#1
0
        /// <summary>
        /// 使用门户查询
        /// </summary>
        /// <param name="objectType"></param>
        /// <param name="criteria"></param>
        /// <param name="loc">如果一个数据层方法需要在本地执行,应该在把本参数指明为 Local。</param>
        /// <returns></returns>
        public static object Fetch(Type objectType, object criteria, DataPortalLocation loc = DataPortalLocation.Dynamic)
        {
            try
            {
                RafyEnvironment.ThreadPortalCount++;

                object res = null;

                //只是不要纯客户端,都直接使用本地访问
                if (loc == DataPortalLocation.Local || RafyEnvironment.Location.ConnectDataDirectly)
                {
                    res = FinalDataPortal.Fetch(objectType, criteria);
                }
                else
                {
                    var proxy = GetDataPortalProxy();

                    var dpContext = CreateDataPortalContext();

                    var result = proxy.Fetch(objectType, criteria, dpContext);

                    res = ReadServerResult(result);
                }

                return(res);
            }
            finally
            {
                RafyEnvironment.ThreadPortalCount--;
            }
        }
示例#2
0
        /// <summary>
        /// Get an existing business object.
        /// </summary>
        /// <param name="objectType">Type of business object to retrieve.</param>
        /// <param name="criteria">Criteria object describing business object.</param>
        /// <param name="context"><see cref="DataPortalContext" /> object passed to the server.</param>
        /// <returns></returns>
        public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context)
        {
            try
            {
                SetContext(context);

                var portal = new FinalDataPortal();
                var result = portal.Fetch(objectType, criteria, context);

                return(result);
            }
            finally
            {
                ClearContext(context);
            }
        }