CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
WcfPortal.cs
Go to the documentation of this file.
1#if !NETSTANDARD2_0 && !NET5_0
2//-----------------------------------------------------------------------
3// <copyright file="WcfPortal.cs" company="Marimer LLC">
4// Copyright (c) Marimer LLC. All rights reserved.
5// Website: https://cslanet.com
6// </copyright>
7// <summary>Exposes server-side DataPortal functionality</summary>
8//-----------------------------------------------------------------------
9using System;
11using System.ServiceModel;
12using System.ServiceModel.Activation;
13using System.Threading.Tasks;
14
15namespace Csla.Server.Hosts
16{
21 [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
22 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
23 public class WcfPortal : IWcfPortal
24 {
29 [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
30 public async Task<WcfResponse> Create(CreateRequest request)
31 {
33 object result;
34 try
35 {
36 result = await portal.Create(request.ObjectType, request.Criteria, request.Context, true);
37 }
38 catch (Exception ex)
39 {
40 result = ex;
41 }
42 return new WcfResponse(result);
43 }
44
49 [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
50 public async Task<WcfResponse> Fetch(FetchRequest request)
51 {
53 object result;
54 try
55 {
56 result = await portal.Fetch(request.ObjectType, request.Criteria, request.Context, true);
57 }
58 catch (Exception ex)
59 {
60 result = ex;
61 }
62 return new WcfResponse(result);
63 }
64
69 [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
70 public async Task<WcfResponse> Update(UpdateRequest request)
71 {
73 object result;
74 try
75 {
76 result = await portal.Update(request.Object, request.Context, true);
77 }
78 catch (Exception ex)
79 {
80 result = ex;
81 }
82 return new WcfResponse(result);
83 }
84
89 [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
90 public async Task<WcfResponse> Delete(DeleteRequest request)
91 {
93 object result;
94 try
95 {
96 result = await portal.Delete(request.ObjectType, request.Criteria, request.Context, true);
97 }
98 catch (Exception ex)
99 {
100 result = ex;
101 }
102 return new WcfResponse(result);
103 }
104 }
105}
106#endif
Implements the server-side DataPortal message router as discussed in Chapter 4.
async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Get an existing business object.
async Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Update a business object.
async Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Create a new business object.
async Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Delete a business object.
Request message for creating a new business object.
object Criteria
Criteria object describing business object.
Type ObjectType
Type of business object to create.
Csla.Server.DataPortalContext Context
Data portal context from client.
Request message for deleting a business object.
object Criteria
Criteria object describing business object.
Csla.Server.DataPortalContext Context
Data portal context from client.
Type ObjectType
Type being requested.
Request message for retrieving an existing business object.
Definition: FetchRequest.cs:19
Csla.Server.DataPortalContext Context
Data portal context from client.
Definition: FetchRequest.cs:63
object Criteria
Criteria object describing business object.
Definition: FetchRequest.cs:54
Type ObjectType
The type of the business object to be retrieved.
Definition: FetchRequest.cs:45
Request message for updating a business object.
Csla.Server.DataPortalContext Context
Data portal context from client.
object Object
Business object to be updated.
Response message for returning the results of a data portal call.
Exposes server-side DataPortal functionality through WCF.
Definition: WcfPortal.cs:24
async Task< WcfResponse > Create(CreateRequest request)
Create a new business object.
Definition: WcfPortal.cs:30
async Task< WcfResponse > Fetch(FetchRequest request)
Get an existing business object.
Definition: WcfPortal.cs:50
async Task< WcfResponse > Update(UpdateRequest request)
Update a business object.
Definition: WcfPortal.cs:70
async Task< WcfResponse > Delete(DeleteRequest request)
Delete a business object.
Definition: WcfPortal.cs:90
Defines the service contract for the WCF data portal.