You are previewing WCF 4.5 Multi-Layer Services Development with Entity Framework.
O'Reilly logo
WCF 4.5 Multi-Layer Services Development with Entity Framework

Book Description

"

If you’re looking for a practical, user-friendly guide to WCF and Entity Framework, here it is – a step-by-step tutorial that focuses on the essentials of building SOA applications on Microsoft to get you started straight away.

  • This book will teach you WCF, Entity Framework, LINQ, and LINQ to Entities quickly and easily.

  • Apply best practices to your WCF services and utilize Entity Framework in your WCF services.

  • Practical, with step-by-step instructions and precise screenshots, this is a truly hands-on book for all C++, C#, and VB.NET developers.

  • In Detail

    WCF is Microsoft's recommended model for building services and Entity Framework is Microsoft’s preferred ORM for accessing underlying data storages. Learning WCF and Entity Framework has become essential and critical for every software developer to survive in this SOA world.

    WCF and Entity Framework are two powerful yet complex technologies, and there are huge reference tomes out there in the market for these two technologies. With this book, you won’t get overwhelmed or scared away by tons of references; instead, you will be given a simple, easy-to-follow approach to get started. For the code solutions within this book, unlike many other WCF and EF books, where you have just one code snippet after another code snippet, all solutions in this book are fully working and completely finished. These solutions are independent of each other, yet built on top of each other, and get more and more sophisticated as the book progresses, so you can learn more advanced WCF and EF techniques easily and quickly.

    This book is a step-by-step tutorial to guide you through learning WCF, Entity Framework, LINQ, and LINQ to Entities. You will be guided to create six WCF and Entity Framework solutions from scratch, of which three are multi-layered real-world WCF service solutions, so you will not only be reading, but also be coding through the book, to gain practical experience of WCF and Entity Framework.

    Various test clients will be associated with each solution and all solutions can be built and run independently of other solutions. Clear instructions and relevant screenshots will make sure you won't get lost in the world of WCF and Entity Framework. Configuration files, host applications, test clients, and WCF services for each solution will also be available for download for you to examine, modify, and debug from the outside in.

    The book focuses on the essentials of using WCF and Entity Framework, rather than providing a reference to every single possibility. It leaves the reference material online where it belongs, and concentrates instead on practical examples, code, and advice.

    "

    Table of Contents

    1. WCF 4.5 Multi-Layer Services Development with Entity Framework
      1. Table of Contents
      2. WCF 4.5 Multi-Layer Services Development with Entity Framework
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
          3. Instant Updates on New Packt Books
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Web Services and Windows Communication Foundation
        1. What is SOA?
        2. Web services
          1. What is a web service?
          2. WSDL
          3. Web service proxy
          4. SOAP
        3. Web services: standards and specifications
          1. WS-I Profiles
          2. WS-Addressing
          3. WS-Security
          4. WS-ReliableMessaging
          5. WS-Coordination and WS-Transaction
        4. Windows Communication Foundation (WCF)
          1. What is WCF?
          2. Why is WCF used for SOA?
          3. WCF architecture
          4. Basic WCF concepts – WCF ABCs
            1. Address
            2. Binding
            3. Contract
              1. Service contract
              2. Operation contract
              3. Message contract
              4. Data contract
              5. Fault contract
            4. Endpoint
            5. Behavior
            6. Hosting
              1. Self hosting
              2. Windows services hosting
              3. IIS or Windows Activation Services hosting
            7. Channels
            8. Metadata
        5. WCF production and development environments
        6. Summary
      9. 2. Implementing a Basic HelloWorld WCF Service
        1. Creating the HelloWorld solution and project
        2. Creating the HelloWorldService service contract interface
        3. Implementing the HelloWorldService service contract
        4. Hosting the WCF service in IIS Express
          1. Creating the host application
          2. Testing the host application
          3. IIS Express
          4. Modifying the web.config file
          5. Starting the host application
        5. Creating a client to consume the WCF service
          1. Creating the client application project
          2. Generating the proxy and configuration files
          3. Customizing the client application
          4. Running the client application
          5. Setting the service application to AutoStart
        6. Summary
      10. 3. Hosting and Debugging the HelloWorld WCF Service
        1. Hosting the HelloWorld WCF service
          1. Hosting the service in ASP.NET Development Server
          2. Hosting the service in a managed application
            1. Hosting the service in a console application
            2. Consuming the service hosted in a console application
          3. Hosting the service in a Windows service
          4. Hosting the service in the Internet Information Services server using the HTTP protocol
            1. Preparing the folders and files
            2. Turn on Internet Information Services
            3. Creating the IIS application
            4. Starting the WCF service in IIS
            5. Testing the WCF service hosted in IIS
          5. Hosting the service in the Internet Information Services server using the TCP protocol
            1. Benefits of hosting a WCF service using the TCP protocol
            2. Preparing the folders and files
            3. Enabling the non-HTTP WCF activation for the hosting machine
            4. Creating the IIS application
            5. Testing the WCF service hosted in IIS using the TCP protocol
          6. Other WCF service hosting options
        2. Debugging the HelloWorld WCF service
          1. Debugging from the client application
            1. Starting the debugging process
            2. Debugging on the client application
            3. Stepping into the WCF service
          2. Directly debugging the WCF service
            1. Starting the WCF service in debugging mode
            2. Starting the client application
          3. Attaching to a running WCF service process
            1. Running the WCF service and client applications in non-debugging mode
            2. Debugging the WCF service hosted in IIS
        3. Summary
      11. 4. Implementing a WCF Service in the Real World
        1. Why layer a service?
        2. Creating a new solution and project using WCF templates
          1. Creating the WCF service project
        3. Creating the service interface layer
          1. Creating the service interfaces
          2. Creating the data contracts
          3. Implementing the service contracts
          4. Modifying the app.config file
          5. Testing the service using WCF Test Client
          6. Testing the service using our own client
        4. Adding a business logic layer
          1. Adding the business domain object project
          2. Adding the business logic project
          3. Calling the business logic layer from the service interface layer
          4. Testing the WCF service with a business logic layer
        5. Summary
      12. 5. Adding Database Support and Exception Handling
        1. Adding a data access layer
          1. Creating the data access layer project
          2. Calling the data access layer from the business logic layer
          3. Preparing the database
          4. Adding the connection string to the configuration file
          5. Querying the database (GetProduct)
          6. Testing the GetProduct method
          7. Updating the database (UpdateProduct)
        2. Adding error handling to the service
          1. Adding a fault contract
          2. Throwing a fault contract exception
          3. Updating the client program to catch the fault exception
          4. Testing the fault exception
        3. Summary
      13. 6. LINQ: Language Integrated Query
        1. What is LINQ?
        2. Creating the test solution and project
        3. Datatype var
        4. Automatic properties
        5. Object initializer
        6. Collection initializer
        7. Anonymous types
        8. Extension methods
        9. Lambda expressions
        10. Built-in LINQ extension methods and method syntax
        11. LINQ query syntax and query expression
        12. Built-in LINQ operators
        13. Summary
      14. 7. LINQ to Entities: Basic Concepts and Features
        1. ORM: Object-Relational Mapping
        2. Entity Framework
        3. LINQ to Entities
        4. Comparing LINQ to Entities with LINQ to Objects
          1. LINQ to SQL
        5. Comparing LINQ to SQL with LINQ to Entities
        6. Creating a LINQ to Entities test application
        7. Creating the data model
          1. Adding a LINQ to Entities item to the project
          2. Generated LINQ to Entities classes
        8. Querying and updating a database table
          1. Querying records
          2. Updating records
          3. Inserting records
          4. Deleting records
          5. Running the program
        9. Viewing generated SQL statements
          1. Viewing SQL statements using ToString
          2. Viewing SQL statements using SQL Profiler
        10. Deferred execution
          1. Checking deferred execution with SQL Profiler
          2. Deferred execution for singleton methods
          3. Deferred execution for singleton methods within sequence expressions
        11. Deferred (lazy) loading versus eager loading
          1. Lazy loading by default
          2. Eager loading with the Include method
          3. Comparing lazy loading and eager loading
        12. Joining two tables
        13. Querying a view
        14. Summary
      15. 8. LINQ to Entities: Advanced Concepts and Features
        1. Calling a stored procedure
          1. Mapping a stored procedure to a new entity class
            1. Modeling a stored procedure
            2. Querying a stored procedure
          2. Mapping a stored procedure to an existing entity class
        2. Inheritance
          1. LINQ to Entities Table per Hierarchy inheritance
            1. Modeling the BaseCustomer and USACustomer entities
            2. Modeling the UKCustomer entity
            3. Generated classes with TPH inheritance
            4. Testing the TPH inheritance
          2. LINQ to Entities Table per Type inheritance
            1. Preparing database tables
            2. Modeling USACustomer1 and UKCustomer1 entities
            3. Generated classes with TPT inheritance
            4. Testing the TPT inheritance
        3. Handling simultaneous (concurrent) updates
          1. Detecting conflicts using a data column
            1. The Concurrency Mode property
            2. Adding another entity data model
            3. Writing the test code
            4. Testing the conflicts
            5. Turning on concurrency control
          2. Detecting conflicts using a version column
            1. Adding a version column
            2. Modeling the Products table with a version column
            3. Writing the test code
            4. Testing the conflicts
        4. Transaction support
          1. Implicit transactions
          2. Explicit transactions
        5. Summary
      16. 9. Applying LINQ to Entities to a WCF Service
        1. Creating the LINQNorthwind solution
        2. Modeling the Northwind database
        3. Creating the business domain object project
        4. Using LINQ to Entities in the data access layer
          1. Adding a reference to the BDO project
          2. Creating GetProduct in the data access layer
          3. Creating UpdateProduct in the data access layer
        5. Creating the business logic layer
        6. Creating the service interface layer
        7. Testing the service with the WCF Test Client
        8. Testing concurrency with our own client
          1. Creating the test client
            1. Implementing the GetProduct functionality
            2. Implementing the UpdateProduct functionality
          2. Testing the GetProduct and UpdateProduct operations
          3. Testing concurrent update manually
          4. Testing concurrent updates automatically
        9. Summary
      17. 10. Distributed Transaction Support of WCF
        1. Creating the DistNorthwind solution
        2. Hosting the WCF service in IIS
        3. Testing the transaction behavior of the WCF service
          1. Creating a client to call the WCF service sequentially
          2. Testing the sequential calls to the WCF service
          3. Wrapping the WCF service calls in one transaction scope
          4. Testing multiple database support of the WCF service
            1. Creating a new WCF service
            2. Calling the new WCF service in the client application
            3. Testing the WCF service with two databases
        4. Enabling distributed transaction support
          1. Enabling transaction flow in service binding
            1. Enabling transaction flow on the service hosting application
          2. Modifying the service operation contract to allow a transaction flow
          3. Modifying the service operation implementation to require a transaction scope
        5. Understanding the distributed transaction support of a WCF service
        6. Testing the distributed transaction support of the WCF service
          1. Configuring the Microsoft Distributed Transaction Coordinator
          2. Configuring the firewall
          3. Propagating a transaction from the client to the WCF service
            1. Testing distributed transaction support with one database
            2. Testing the distributed transaction support with two databases
        7. Tradeoffs of distributed transactions
        8. Summary
      18. 11. WCF Security
        1. WCF security components
          1. WCF authorization
          2. WCF auditing
          3. WCF transfer security
            1. WCF security modes
            2. WCF transport security
            3. WCF message security
            4. WCF mixed security
            5. WCF transport and message (both) security
            6. Authentication options for transport security
            7. Authentication options for message security
        2. Hosting a WCF service using Basic Authentication
          1. Setting up the service
          2. Enabling the Basic Authentication feature
          3. Configuring Basic Authentication on IIS
          4. Configuring the HTTPS protocol
          5. Configuring Basic Authentication on the service
          6. Testing the service with Basic Authentication
        3. Hosting a WCF service with Windows Authentication
        4. WCF Security Guidance
        5. Summary
      19. 12. Extending WCF Services
        1. WCF runtime architecture
        2. Why extend WCF services?
        3. WCF extension points
          1. Client-side extension points
          2. Service-side extension points
        4. Extending a WCF service
          1. WCF extension classes
          2. WCF behavior classes
          3. WCF behavior element classes
          4. Applying the extensions
        5. Extending HelloWorldService
          1. Setting up the service
          2. Creating the extension project
          3. Creating an extension class
          4. Creating a behavior class
          5. Creating a behavior element class
          6. Applying the extension to HelloWorldService
          7. Testing the extended HelloWorldService
        6. Summary
      20. Index