Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
WCF Multi-layer Services Development with Entity Framework - Fourth Edition

You're reading from   WCF Multi-layer Services Development with Entity Framework - Fourth Edition Create and deploy complete solutions with WCF and Entity Framework

Arrow left icon
Product type Paperback
Published in Oct 2014
Publisher
ISBN-13 9781784391041
Length 378 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Mike Liu Mike Liu
Author Profile Icon Mike Liu
Mike Liu
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Implementing a Basic HelloWorld WCF Service 2. Hosting the HelloWorld WCF Service FREE CHAPTER 3. Deploying the HelloWorld WCF Service 4. Debugging the HelloWorld WCF Service 5. Implementing a Three-layer WCF Service 6. Adding Database Support and Exception Handling 7. LINQ to Entities – Basic Concepts and Features 8. LINQ to Entities – Advanced Concepts and Features 9. Applying LINQ to Entities to a WCF Service 10. Distributed Transaction Support of WCF 11. Building a RESTful WCF Service 12. WCF Security 13. Extending WCF Services Index

Viewing the generated SQL statements


You might wonder which SQL statements are used by LINQ to Entities to interact with the databases. In this section, we will use two ways to view the generated SQL statements used by LINQ to Entities queries. The first one is to use the ToString method and the second one is to use SQL Profiler.

Viewing the SQL statements using ToString

First, let's write a new test method to contain one LINQ to Entities query:

        static void ViewGeneratedSQL()
        {
            using(var NWEntities = 
                new NorthwindEntities())
           {

            var beverages = 
                from p in NWEntities.Products
                where p.Category.CategoryName == "Beverages"
                orderby p.ProductName
                select p;
            }
        }

Now, we can print out the SQL statement of the LINQ to Entities query using the following statement:

       // view SQL using ToString method
       Console.WriteLine("The SQL statement is:" +...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime