/// <summary>
        /// Update a business object.
        /// </summary>
        /// <param name="request">The request parameter object.</param>
        /// <returns>Result of the update operation - updated object</returns>
        public MobileResponse Update(MobileUpdateRequest request)
        {
            var    result = new MobileResponse();
            Type   t      = null;
            object obj    = null;

            try
            {
                // unpack object
                obj = request.ObjectToUpdate;

                // load type for business object
                t = obj.GetType();

                object o           = null;
                var    factoryInfo = GetMobileFactoryAttribute(t);
                if (factoryInfo == null)
                {
                    SetContext(request);

                    new Csla.Server.DataPortal().Authorize(new AuthorizeRequest(t, obj, DataPortalOperations.Update));

                    o = Csla.DataPortal.Update(obj);
                }
                else
                {
                    if (string.IsNullOrEmpty(factoryInfo.UpdateMethodName))
                    {
                        throw new InvalidOperationException(Resources.UpdateMethodNameNotSpecified);
                    }

                    SetContext(request);

                    new Csla.Server.DataPortal().Authorize(new AuthorizeRequest(t, obj, DataPortalOperations.Update));

                    object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
                    o = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.UpdateMethodName, obj);
                }
                result.Object        = o;
                result.GlobalContext = ApplicationContext.GlobalContext;
            }
            catch (Csla.Reflection.CallMethodException ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(t, obj, "DataPortal.Update", ex);
                result.Error = inspected.InnerException;
            }
            catch (Exception ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(t, obj, "DataPortal.Update", ex);
                result.Error = inspected;
            }
            finally
            {
                ClearContext();
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// Create a new business object.
        /// </summary>
        /// <param name="request">The request parameter object.</param>
        /// <returns>Resulf of the create operation - an instance of a business object</returns>
        public async Task <MobileResponse> Create(MobileCriteriaRequest request)
        {
            var    serverDataPortal   = new Csla.Server.DataPortal();
            var    result             = new MobileResponse();
            Type   businessObjectType = null;
            object criteria           = null;

            try
            {
                criteria = request.Criteria;
                // load type for business object
                businessObjectType = Type.GetType(request.TypeName);
                if (businessObjectType == null)
                {
                    throw new InvalidOperationException(
                              string.Format(Csla.Properties.Resources.ObjectTypeCouldNotBeLoaded, request.TypeName));
                }

                SetContext(request);

                serverDataPortal.Initialize(new InterceptArgs {
                    ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Create
                });
                serverDataPortal.Authorize(new AuthorizeRequest(businessObjectType, criteria, DataPortalOperations.Create));

                object newObject   = null;
                var    factoryInfo = GetMobileFactoryAttribute(businessObjectType);
                if (factoryInfo == null)
                {
                    if (criteria != null)
                    {
                        newObject = await Csla.Reflection.MethodCaller.CallGenericStaticMethodAsync(typeof(Csla.DataPortal), "CreateAsync", new Type[] { businessObjectType }, true, criteria).ConfigureAwait(false);
                    }
                    else
                    {
                        newObject = await Csla.Reflection.MethodCaller.CallGenericStaticMethodAsync(typeof(Csla.DataPortal), "CreateAsync", new Type[] { businessObjectType }, false, null).ConfigureAwait(false);
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(factoryInfo.CreateMethodName))
                    {
                        throw new InvalidOperationException(Resources.CreateMethodNameNotSpecified);
                    }

                    object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
                    if (criteria != null)
                    {
                        newObject = await Csla.Reflection.MethodCaller.CallMethodTryAsync(f, factoryInfo.CreateMethodName, criteria).ConfigureAwait(false);
                    }
                    else
                    {
                        newObject = await Csla.Reflection.MethodCaller.CallMethodTryAsync(f, factoryInfo.CreateMethodName).ConfigureAwait(false);
                    }
                }
                result.Object = newObject;
#pragma warning disable CS0618 // Type or member is obsolete
                result.GlobalContext = ApplicationContext.GlobalContext;
#pragma warning restore CS0618 // Type or member is obsolete
            }
            catch (Csla.Reflection.CallMethodException ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, criteria, "DataPortal.Create", ex);
                result.Error = inspected.InnerException;
            }
            catch (Exception ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, criteria, "DataPortal.Create", ex);
                result.Error = inspected;
            }
            finally
            {
                if (result.Error != null)
                {
                    serverDataPortal.Complete(new InterceptArgs {
                        ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Create, Exception = result.Error, Result = new DataPortalResult(result.Object, result.Error, result.GlobalContext)
                    });
                }
                else
                {
                    serverDataPortal.Complete(new InterceptArgs {
                        ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Create, Result = new DataPortalResult(result.Object, result.GlobalContext)
                    });
                }
                ClearContext();
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Update a business object.
        /// </summary>
        /// <param name="request">The request parameter object.</param>
        /// <returns>Result of the update operation - updated object</returns>
        public async Task <MobileResponse> Update(MobileUpdateRequest request)
        {
            var    serverDataPortal   = new Csla.Server.DataPortal();
            var    result             = new MobileResponse();
            Type   businessObjectType = null;
            object obj       = null;
            var    operation = DataPortalOperations.Update;

            try
            {
                // unpack object
                obj = request.ObjectToUpdate;

                if (obj is Csla.Core.ICommandObject)
                {
                    operation = DataPortalOperations.Execute;
                }

                // load type for business object
                businessObjectType = obj.GetType();

                SetContext(request);

                serverDataPortal.Initialize(new InterceptArgs {
                    ObjectType = businessObjectType, Parameter = obj, Operation = operation
                });
                serverDataPortal.Authorize(new AuthorizeRequest(businessObjectType, obj, operation));

                object newObject   = null;
                var    factoryInfo = GetMobileFactoryAttribute(businessObjectType);
                if (factoryInfo == null)
                {
                    newObject = await Csla.Reflection.MethodCaller.CallGenericStaticMethodAsync(typeof(Csla.DataPortal), "UpdateAsync", new Type[] { businessObjectType }, true, obj).ConfigureAwait(false);
                }
                else
                {
                    if (string.IsNullOrEmpty(factoryInfo.UpdateMethodName))
                    {
                        throw new InvalidOperationException(Resources.UpdateMethodNameNotSpecified);
                    }

                    object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
                    newObject = await Csla.Reflection.MethodCaller.CallMethodTryAsync(f, factoryInfo.UpdateMethodName, obj).ConfigureAwait(false);
                }
                result.Object = newObject;
#pragma warning disable CS0618 // Type or member is obsolete
                result.GlobalContext = ApplicationContext.GlobalContext;
#pragma warning restore CS0618 // Type or member is obsolete
            }
            catch (Csla.Reflection.CallMethodException ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, obj, "DataPortal.Update", ex);
                result.Error = inspected.InnerException;
            }
            catch (Exception ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, obj, "DataPortal.Update", ex);
                result.Error = inspected;
            }
            finally
            {
                if (result.Error != null)
                {
                    serverDataPortal.Complete(new InterceptArgs {
                        ObjectType = businessObjectType, Parameter = obj, Operation = operation, Exception = result.Error, Result = new DataPortalResult(result.Object, result.Error, result.GlobalContext)
                    });
                }
                else
                {
                    serverDataPortal.Complete(new InterceptArgs {
                        ObjectType = businessObjectType, Parameter = obj, Operation = operation, Result = new DataPortalResult(result.Object, result.GlobalContext)
                    });
                }
                ClearContext();
            }
            return(result);
        }
예제 #4
0
        public async Task <MobileResponse> Fetch(MobileCriteriaRequest request)
#endif
        {
            var    serverDataPortal   = new Csla.Server.DataPortal();
            var    result             = new MobileResponse();
            Type   businessObjectType = null;
            object criteria           = null;

            try
            {
                // unpack criteria data into object
                criteria = request.Criteria;

                // load type for business object
                businessObjectType = Type.GetType(request.TypeName);
                if (businessObjectType == null)
                {
                    throw new InvalidOperationException(
                              string.Format(Resources.ObjectTypeCouldNotBeLoaded, request.TypeName));
                }

                SetContext(request);

                serverDataPortal.Initialize(new InterceptArgs {
                    ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Fetch
                });
                serverDataPortal.Authorize(new AuthorizeRequest(businessObjectType, criteria, DataPortalOperations.Fetch));

                object newObject   = null;
                var    factoryInfo = GetMobileFactoryAttribute(businessObjectType);
                if (factoryInfo == null)
                {
#if NET40
                    if (criteria == null)
                    {
                        newObject = Csla.DataPortal.Fetch(businessObjectType, new EmptyCriteria());
                    }
                    else
                    {
                        newObject = Csla.DataPortal.Fetch(businessObjectType, criteria);
                    }
#else
                    if (criteria != null)
                    {
                        newObject = await Csla.Reflection.MethodCaller.CallGenericStaticMethodAsync(typeof(Csla.DataPortal), "FetchAsync", new Type[] { businessObjectType }, true, criteria).ConfigureAwait(false);
                    }
                    else
                    {
                        newObject = await Csla.Reflection.MethodCaller.CallGenericStaticMethodAsync(typeof(Csla.DataPortal), "FetchAsync", new Type[] { businessObjectType }, false, null).ConfigureAwait(false);
                    }
#endif
                }
                else
                {
                    if (string.IsNullOrEmpty(factoryInfo.FetchMethodName))
                    {
                        throw new InvalidOperationException(Resources.FetchMethodNameNotSpecified);
                    }

                    object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
#if NET40
                    if (criteria != null)
                    {
                        newObject = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.FetchMethodName, criteria);
                    }
                    else
                    {
                        newObject = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.FetchMethodName);
                    }
#else
                    if (criteria != null)
                    {
                        newObject = await Csla.Reflection.MethodCaller.CallMethodTryAsync(f, factoryInfo.FetchMethodName, criteria).ConfigureAwait(false);
                    }
                    else
                    {
                        newObject = await Csla.Reflection.MethodCaller.CallMethodTryAsync(f, factoryInfo.FetchMethodName).ConfigureAwait(false);
                    }
#endif
                }
                result.Object        = newObject;
                result.GlobalContext = ApplicationContext.GlobalContext;
            }
            catch (Csla.Reflection.CallMethodException ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, criteria, "DataPortal.Fetch", ex);
                result.Error = inspected.InnerException;
            }
            catch (Exception ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, criteria, "DataPortal.Fetch", ex);
                result.Error = inspected;
            }
            finally
            {
                if (result.Error != null)
                {
                    serverDataPortal.Complete(new InterceptArgs {
                        ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Fetch, Exception = result.Error, Result = new DataPortalResult(result.Object, result.Error, result.GlobalContext)
                    });
                }
                else
                {
                    serverDataPortal.Complete(new InterceptArgs {
                        ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Fetch, Result = new DataPortalResult(result.Object, result.GlobalContext)
                    });
                }
                ClearContext();
            }
            return(result);
        }
예제 #5
0
    public async Task<MobileResponse> Create(MobileCriteriaRequest request)
#endif
    {
      var serverDataPortal = new Csla.Server.DataPortal();
      var result = new MobileResponse();
      Type businessObjectType = null;
      object criteria = null;
      try
      {
        criteria = request.Criteria;
        // load type for business object
        businessObjectType = Type.GetType(request.TypeName);
        if (businessObjectType == null)
          throw new InvalidOperationException(
            string.Format(Csla.Properties.Resources.ObjectTypeCouldNotBeLoaded, request.TypeName));

        SetContext(request);

        serverDataPortal.Initialize(new InterceptArgs { ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Create });
        serverDataPortal.Authorize(new AuthorizeRequest(businessObjectType, criteria, DataPortalOperations.Create));

        object newObject = null;
        var factoryInfo = GetMobileFactoryAttribute(businessObjectType);
        if (factoryInfo == null)
        {
#if NET40
          if (criteria != null)
            newObject = Csla.DataPortal.Create(businessObjectType, criteria);
          else
            newObject = Csla.DataPortal.Create(businessObjectType, new EmptyCriteria());
#else
          if (criteria != null)
            newObject = await Csla.Reflection.MethodCaller.CallGenericStaticMethodAsync(typeof(Csla.DataPortal), "CreateAsync", new Type[] { businessObjectType }, true, criteria).ConfigureAwait(false);
          else
            newObject = await Csla.Reflection.MethodCaller.CallGenericStaticMethodAsync(typeof(Csla.DataPortal), "CreateAsync", new Type[] { businessObjectType }, false, null).ConfigureAwait(false);
#endif
        }
        else
        {
          if (string.IsNullOrEmpty(factoryInfo.CreateMethodName))
            throw new InvalidOperationException(Resources.CreateMethodNameNotSpecified);

          object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
#if NET40
          if (criteria != null)
            newObject = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.CreateMethodName, criteria);
          else
            newObject = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.CreateMethodName);
#else
          if (criteria != null)
            newObject = await Csla.Reflection.MethodCaller.CallMethodTryAsync(f, factoryInfo.CreateMethodName, criteria).ConfigureAwait(false);
          else
            newObject = await Csla.Reflection.MethodCaller.CallMethodTryAsync(f, factoryInfo.CreateMethodName).ConfigureAwait(false);
#endif
        }
        result.Object = newObject;
        result.GlobalContext = ApplicationContext.GlobalContext;
      }
      catch (Csla.Reflection.CallMethodException ex)
      {
        var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, criteria, "DataPortal.Create", ex);
        result.Error = inspected.InnerException;
      }
      catch (Exception ex)
      {
        var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, criteria, "DataPortal.Create", ex);
        result.Error = inspected;
      }
      finally
      {
        if (result.Error != null)
          serverDataPortal.Complete(new InterceptArgs { ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Create, Exception = result.Error, Result = new DataPortalResult(result.Object, result.Error, result.GlobalContext) });
        else
          serverDataPortal.Complete(new InterceptArgs { ObjectType = businessObjectType, Parameter = criteria, Operation = DataPortalOperations.Create, Result = new DataPortalResult(result.Object, result.GlobalContext) });
        ClearContext();
      }
      return result;
    }
예제 #6
0
    public async Task<MobileResponse> Update(MobileUpdateRequest request)
#endif
    {
      var serverDataPortal = new Csla.Server.DataPortal();
      var result = new MobileResponse();
      Type businessObjectType = null;
      object obj = null;
      var operation = DataPortalOperations.Update;
      try
      {
        // unpack object
        obj = request.ObjectToUpdate;

        if (obj is Csla.Core.ICommandObject)
          operation = DataPortalOperations.Execute;

        // load type for business object
        businessObjectType = obj.GetType();

        SetContext(request);

        serverDataPortal.Initialize(new InterceptArgs { ObjectType = businessObjectType, Parameter = obj, Operation = operation });
        serverDataPortal.Authorize(new AuthorizeRequest(businessObjectType, obj, operation));

        object newObject = null;
        var factoryInfo = GetMobileFactoryAttribute(businessObjectType);
        if (factoryInfo == null)
        {
#if NET40
          newObject = Csla.DataPortal.Update(obj);
#else
          newObject = await Csla.Reflection.MethodCaller.CallGenericStaticMethodAsync(typeof(Csla.DataPortal), "UpdateAsync", new Type[] { businessObjectType }, true, obj).ConfigureAwait(false);
#endif
        }
        else
        {
          if (string.IsNullOrEmpty(factoryInfo.UpdateMethodName))
            throw new InvalidOperationException(Resources.UpdateMethodNameNotSpecified);

          object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
#if NET40
          newObject = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.UpdateMethodName, obj);
#else
          newObject = await Csla.Reflection.MethodCaller.CallMethodTryAsync(f, factoryInfo.UpdateMethodName, obj).ConfigureAwait(false);
#endif
        }
        result.Object = newObject;
        result.GlobalContext = ApplicationContext.GlobalContext;
      }
      catch (Csla.Reflection.CallMethodException ex)
      {
        var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, obj, "DataPortal.Update", ex);
        result.Error = inspected.InnerException;
      }
      catch (Exception ex)
      {
        var inspected = new DataPortalExceptionHandler().InspectException(businessObjectType, obj, "DataPortal.Update", ex);
        result.Error = inspected;
      }
      finally
      {
        if (result.Error != null)
          serverDataPortal.Complete(new InterceptArgs { ObjectType = businessObjectType, Parameter = obj, Operation = operation, Exception = result.Error, Result = new DataPortalResult(result.Object, result.Error, result.GlobalContext) });
        else
          serverDataPortal.Complete(new InterceptArgs { ObjectType = businessObjectType, Parameter = obj, Operation = operation, Result = new DataPortalResult(result.Object, result.GlobalContext) });
        ClearContext();
      }
      return result;
    }
예제 #7
0
    /// <summary>
    /// Create a new business object.
    /// </summary>
    /// <param name="request">The request parameter object.</param>
    /// <returns>Resulf of the create operation - an instance of a business object</returns>
    public MobileResponse Create(MobileCriteriaRequest request)
    {
      var result = new MobileResponse();
      Type t = null;
      object criteria = null;
      try
      {
        criteria = request.Criteria;
        // load type for business object
        t = Type.GetType(request.TypeName);
        if (t == null)
          throw new InvalidOperationException(
            string.Format(Csla.Properties.Resources.ObjectTypeCouldNotBeLoaded, request.TypeName));

        SetContext(request);

        new Csla.Server.DataPortal().Authorize(new AuthorizeRequest(t, criteria, DataPortalOperations.Create));

        object o = null;
        var factoryInfo = GetMobileFactoryAttribute(t);
        if (factoryInfo == null)
        {
          if (criteria != null)
          {
            o = Csla.DataPortal.Create(t, criteria);
          }
          else
          {
            o = Csla.DataPortal.Create(t, new EmptyCriteria());
          }
        }
        else
        {
          if (string.IsNullOrEmpty(factoryInfo.CreateMethodName))
            throw new InvalidOperationException(Resources.CreateMethodNameNotSpecified);

          object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
          if (criteria != null)
            o = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.CreateMethodName, criteria);
          else
            o = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.CreateMethodName);
        }
        result.Object = o;
        result.GlobalContext = ApplicationContext.GlobalContext;
      }
      catch (Csla.Reflection.CallMethodException ex)
      {
        var inspected = new DataPortalExceptionHandler().InspectException(t, criteria, "DataPortal.Create", ex);
        result.Error = inspected.InnerException;
      }
      catch (Exception ex)
      {
        var inspected = new DataPortalExceptionHandler().InspectException(t, criteria, "DataPortal.Create", ex);
        result.Error = inspected;
      }
      finally
      {
        ClearContext();
      }
      return result;
    }
예제 #8
0
    /// <summary>
    /// Update a business object.
    /// </summary>
    /// <param name="request">The request parameter object.</param>
    /// <returns>Result of the update operation - updated object</returns>
    public MobileResponse Update(MobileUpdateRequest request)
    {
      var result = new MobileResponse();
      Type t = null;
      object obj = null;
      try
      {
        // unpack object
        obj = request.ObjectToUpdate;

        // load type for business object
        t = obj.GetType();

        object o = null;
        var factoryInfo = GetMobileFactoryAttribute(t);
        if (factoryInfo == null)
        {
          SetContext(request);

          new Csla.Server.DataPortal().Authorize(new AuthorizeRequest(t, obj, DataPortalOperations.Update));

          o = Csla.DataPortal.Update(obj);
        }
        else
        {
          if (string.IsNullOrEmpty(factoryInfo.UpdateMethodName))
            throw new InvalidOperationException(Resources.UpdateMethodNameNotSpecified);

          SetContext(request);

          new Csla.Server.DataPortal().Authorize(new AuthorizeRequest(t, obj, DataPortalOperations.Update));

          object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
          o = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.UpdateMethodName, obj);
        }
        result.Object = o;
        result.GlobalContext = ApplicationContext.GlobalContext;
      }
      catch (Csla.Reflection.CallMethodException ex)
      {
        var inspected = new DataPortalExceptionHandler().InspectException(t, obj, "DataPortal.Update", ex);
        result.Error = inspected.InnerException;
      }
      catch (Exception ex)
      {
        var inspected = new DataPortalExceptionHandler().InspectException(t, obj, "DataPortal.Update", ex);
        result.Error = inspected;
      }
      finally
      {
        ClearContext();
      }
      return result;
    }
        /// <summary>
        /// Create a new business object.
        /// </summary>
        /// <param name="request">The request parameter object.</param>
        /// <returns>Resulf of the create operation - an instance of a business object</returns>
        public MobileResponse Create(MobileCriteriaRequest request)
        {
            var    result   = new MobileResponse();
            Type   t        = null;
            object criteria = null;

            try
            {
                criteria = request.Criteria;
                // load type for business object
                t = Type.GetType(request.TypeName);
                if (t == null)
                {
                    throw new InvalidOperationException(
                              string.Format(Csla.Properties.Resources.ObjectTypeCouldNotBeLoaded, request.TypeName));
                }

                SetContext(request);

                new Csla.Server.DataPortal().Authorize(new AuthorizeRequest(t, criteria, DataPortalOperations.Create));

                object o           = null;
                var    factoryInfo = GetMobileFactoryAttribute(t);
                if (factoryInfo == null)
                {
                    if (criteria != null)
                    {
                        o = Csla.DataPortal.Create(t, criteria);
                    }
                    else
                    {
                        o = Csla.DataPortal.Create(t, new EmptyCriteria());
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(factoryInfo.CreateMethodName))
                    {
                        throw new InvalidOperationException(Resources.CreateMethodNameNotSpecified);
                    }

                    object f = FactoryLoader.GetFactory(factoryInfo.FactoryTypeName);
                    if (criteria != null)
                    {
                        o = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.CreateMethodName, criteria);
                    }
                    else
                    {
                        o = Csla.Reflection.MethodCaller.CallMethod(f, factoryInfo.CreateMethodName);
                    }
                }
                result.Object        = o;
                result.GlobalContext = ApplicationContext.GlobalContext;
            }
            catch (Csla.Reflection.CallMethodException ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(t, criteria, "DataPortal.Create", ex);
                result.Error = inspected.InnerException;
            }
            catch (Exception ex)
            {
                var inspected = new DataPortalExceptionHandler().InspectException(t, criteria, "DataPortal.Create", ex);
                result.Error = inspected;
            }
            finally
            {
                ClearContext();
            }
            return(result);
        }