WCF CRUDS and .NET Core 3.1 Forms

In this tutorial we'll learn developing distributed client server desktop application using windows forms and CRUD2CRUD (CRUDS) communication architecture.

We have already learnt about CRUDS architecture in Introduction to CRUDS tutorial. CRUDS enable IService, IServiceAsync, IWCFService and IWCFServiceAsync communication channels and implement ICRUD, ICRUDL and ICRUDM interfaces.

Keywords: windntrees, windows, desktop, .net core 3.1 forms, CRUD, CRUD2CRUD, CRUDS
  • Benefits

    CRUDS architecture implementation brings following benefits:

    1. Generalized Communication CRUD2CRUD (CRUDS)
    2. One interface, no need for multiple service contract interfaces.
    3. CRUD Repositories for data persistence.
    4. Extend CRUD repositories with customized functions and integrate in CRUD controllers (CRUD Services) with one IService (or IWCFService).
    5. Invoke remote methods from clients (ServiceClients CRUDController) by specifying server side method "target" names.
    6. Support for MVVM desktop and Xamarin mobile application development. WCF CRUDS application server.
    7. Cross-process and cross-platform clients.
    8. Data communication using synchronous (IService, IWCFService) and asynchronous (IServiceAsync, IWCFServiceAsync) interface channels.
    9. Support for event driven response handling and GUI integration.
    10. Support for paging or listing based records.
    11. Reduced effort and cost of developing multiple service contracts. Think of CRUDL communication with CRUD repository for persistence.
    12. Reduced complexity and elaborated architecture (CRUDLM data communication).
    13. Distribute applications with simple interfacing programming model.

    Strategy

    To achieve tutorial objectives we'll develop:

    1. Application Server Project (.NET Framework).
    2. Forms Application Client (.NET Core 3.1).
    3. Shared Library Project (.NET Standard) and,
    4. Setup Database (Script Included).

    Database Setup

    Install or run "tutorials" database script in MS-SQL Server 2017 or latest edition that includes related tables and data.

  • Application Server Project

    Application server enables distributed clients with operational logic with same database, repositories and standard data models.

    1. Setup new windows .NET Framework console application project.
    2. Install WindnTrees.CRUDS and dependent latest nuget packages.
    3. Create Entity Framework Entity Model (.edmx) that includes database application context and POCO models.
    4. Configure Entity Model with Shared Library project for distributing standard data models (POCO classes) across different projects.
    5. Write IWCFService service respositories for .NET Framework and .NET Core Framework.
    6. Create new ApplicationServer class and inherit from WindnTrees.CRUDS.Server class.
    7. Host service repositories using IWCFService channel interface in ApplicationServer.

    Windows Forms Application (.NET Core)

    Windows Forms enable desktop user operational logic and are setup as mentioned below:

    1. Setup Windows Forms .NET Core application project.
    2. Install WindnTrees.ICRUDS.Standard nuget package.
    3. Add Entity Framework shared library project reference.
    4. Instantiate service clients using interface channels (IService, IServiceAsync, IWCFService, IWCFServiceAsync) with bindings and endpoints.
    5. Integrate service client methods and update GUI accordingly.
    6. Integrate application logic and continue developing distributed clients using CRUDS architecture with one interface and many repositories.

    Make sure IP and port configurations are same when using .NET Forms Application with Server. This project uses 9096 port for net.tcp protocol implementation.

    Shared Library

    Shares common data model or data contract definitions required to communicate data across or within different components of a sub-system. In this application we'll share following data contract model:

    1. Product
  • ServiceClient and Events

    WindnTrees CRUDS support 3 types of data communication and handling.

    1. Synchronous (IService, IWCFService)
    2. Asynchronous with Local Delegates (Not supported in .NET Core)
    3. Asynchronous with Service Side Implementation (IServiceAsync, IWCFServiceAsync)

    In this tutorial we'll implement CRUDS synchronous communication interface channel. Local asynchronous events are not supported.

    Call following CRUDS service client method to get primitive data type object response.

    1. MethodSearchObject

    Call following CRUDS service client method to get generic type (WCFServiceClient) data response.

    1. Create
    2. Update
    3. Delete

    Call following CRUDS service client method to get generic type (WCFServiceClient) listing (List) data response.

    1. List

    Visit windntrees to learn about ServiceClient and WCFServiceClient APIs.

    Application Server Nuget Packages

    WCF CRUDS Server (CRUD2CRUD) depend upon following nuget packages.

    1. WindnTrees.CRUDS
    2. WindnTrees.ICRUDS.Standard
    3. WindnTrees.CRUDS.Repository

    Repository for .NET standard interfacing channel is part of WindnTrees.CRUDS nuget package.

    Windows Forms (.NET Core) Nuget Packages

    Windows Forms depend upon following nuget packages.

    1. WindnTrees.ICRUDS.Standard

    Summary

    WindnTrees.CRUDS provide efficient means of developing cross-process, cross-platform distributed applications using CRUD2CRUD communication architecture. Download projects code here. Nuget packages are not included in download.