• Home
  • About
  • BestBloggingIdeas
  • DotNetLearningSource
  • FORUM
  • Joblinks
  • Latest News
  • Policy
  • POSTS
  • SimplySqlServer.Com && SimplyAspDotNet.Com
  • Sitemap

Join Ours Forum

Asp.Net,C#,Ajax,Sql server,silverlight,Javascript codes exambles articles,Programming exambles

RSS Feed
  • Bounty Huge Roll [Amazon Frustration-Free Packaging]
  • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
  • The Basic Overview of Windows Mobile Development Asp.Net C#
  • Overview of Sql server extended properties Asp.Net C#
  • How to Use Sql Server Extended properties using visual studio Asp.Net C#
  • Adobe Dreamweaver Templates Accelerate Web Development
  • Top Tips for Web Design Projects
  • How to Achieve a Good Web Design Structure
  • To Use Or Not To Use Website Templates
  • Five Tips to a Successful Website
  • Top 10 Articles,


    Silverlight Datagrid Select Update Delete Insert Asp.Net C#

    Differences Similarities Benefits Between Typed Datasets and Untyped Datasets asp.net c#

    Linq to Sql Introduction Entities Ado.Net C# SqlClasses Attributes Linq Mapping

    Linq Programming/How Linq Works?/Linq Implementation In Asp.Net C# Ado.Net

    Performing Developing Using Investigating Asp.Net 2.0 Ajax Application Development Asp.Net C#

    Hosting/Install Wcf Services in a Windows Service Asp.Net C#

    Connecting Silverlight to Wcf Asp.Net C#

    Silverlight Data Grid Data Binding WCF Asp.Net C#

    Invoking/Accessing/Calling WCF Service Without Adding/Creating Proxy/Reference Asp.Net C#

    Performing Doing Creating Insert Update Delete sql data Using Linq Database Asp.Net C#

    Using/Coding/Programming Entity Framework in Silverlight with Visual Basic Asp.Net C#

    Posted by james on March 11, 2011 Leave a comment (0) Go to comments

    Using Entity Framework in Silverlight with Visual Basic

    A common requirement in building applications is the need to serialize objects and pass them across tiers between the server and the client. These objects typically hold references to each other, and managing this “graph” and tracking all the changes so that they can be properly persisted to the database can get complicated quickly.



    > >
    In Visual Studio 2010 and .NET 4.0, the Entity Framework team added a template for generating self-tracking entities (STEs) to provide an easier experience building N-tier applications that need to send entities with changes between tiers. These entities are business objects that have no direct dependency on the Entity Framework, but know how to track their own changes, so that they can later be re-attached to an ObjectContext and the changes correctly merged back.

    One of the most common questions we’ve received about STEs is whether these entities are compatible with other platforms such as Silverlight, and if so what are the best practices for structuring your solution. In this article, using Visual Basic 2010, we will build a Silverlight product catalog application using a WCF service and self-tracking entities as the payload between Silverlight and the service. We’ll see how new VB language features such as statement lambdas and implicit line continuation allow you to be even more productive with technologies like Silverlight and Entity Framework.

    Creating the Silverlight Application with Visual Studio 2010

    The challenge with using the self-tracking entities template with Silverlight is that not all Silverlight and .NET assemblies can be shared between the two platforms. In Silverlight 4.0, a new feature called assembly portability was introduced that allows some .NET assemblies to be used with Silverlight. Some of the pieces of self-tracking entities such as the DataContract attributes and the ObservableCollection(Of T) classes are not in portable assemblies so that strategy will not work here.

    However, because both Silverlight and .NET support WCF data contract serialization, the data contract of your communication payload can be shared when sending messages between Silverlight and .NET. In practice, you can accomplish this if you define a class in .NET that has the same and attributes as a similar class that you define in Silverlight; the WCF serializers and deserializers take care of the rest. In the case of self-tracking entities, we will need to have two references to the self-tracking entities code in our solution: one reference from a .NET project and one reference from a Silverlight project.

    To get started building the product catalog application, open Visual Studio 2010 and create a new Silverlight Application project called ProductsCatalog (Figure 1).

    Click for a larger version of this image.
    Figure 1: Creating a New Project. If you don’t have the latest Silverlight developer tools installed, you will be prompted by Visual Studio to install these.

    Visual Studio brings up a dialog box (Figure 2) asking how you want to host your Silverlight application. Choose to go with the defaults and host the Silverlight application in a new ASP.NET Web Application Project called ProductsCatalog.Web.

    Click for a larger version of this image.
    Figure 2: The New Silverlight Application dialog box. After pressing OK, a Silverlight Application project and a .NET ASP.NET Web Application project is created in the Solution Explorer (Figure 3)

    Click for a larger version of this image.
    Figure 3: What you should see in Solution Explorer. Next you have to make a decision because there are a few options for how to expose the service and the entities you pass between the service and the Silverlight application. First consider where to put the service. The options you have are to either add a service control to the ProductsCatalog.Web project, or to add a new WCF project to your solution to manage your services. The decision comes down to how you plan to host your web site and how you are already managing other services in your application or business. To keep things simple, we’ll just add the WCF service to the ProductsCatalog.Web project.

    To do this, right-click on the ProductsCatalog.Web project and choose Add | New Item… In the Add New Item dialog box (Figure 4), click on the Silverlight category and then choose to add a Silverlight-enabled WCF Service. We’ve chosen to name ours CatalogService.svc.

    Click for a larger version of this image.
    Figure 4: Adding the WCF Service. The final decision to make for setting up your Visual Studio solution is where to keep the Silverlight version of your entities. Again there are two options: build them into the existing Silverlight application, or create a new Silverlight class library that you can reference in your Silverlight application. If this is the only Silverlight application that will use your entities, it is fine to just build them into your existing Silverlight application project. If you plan to share the entities with other Silverlight applications or with other Silverlight class libraries, you should put them in their own class library, which is what we’ll do for our product catalog application.

    To add a Silverlight class library, right-click on the Visual Studio solution and choose Add | New Project … In the Add New Project dialog box (Figure 5), select the Silverlight category and choose the Silverlight Class Library project type. In this example name it SilverlightEntities.

    Click for a larger version of this image.
    Figure 5: Adding the Silverlight Class Library. When you click OK, you are prompted to choose the version of Silverlight you are targeting (Figure 6) and in this case this is Silverlight 4.

    Click for a larger version of this image.
    Figure 6: Choosing the Silverlight version. You can remove the Class1.vb file that is added to this project by default.

    The final step is to have the ProductsCatalog Silverlight application reference the SilverlightEntities class library. To do this, right-click on the References folder in the ProductsCatalog project (if this is not visible select the “Show All Files” button in Solution Explorer) and choose Add Reference… From the Add Reference dialog box, click on the Projects tab and select the SilverlightEntities project. This will set up the reference so you can use classes from the SilverlightEntities project within the ProductsCatalog Silverlight application.

    Once you’ve completed these steps, your solution should look like Figure 7, with a ProductsCatalog project, a SilverlightEntities project, and a ProductsCatalog.Web project with a CatalogService.svc file added.


    Click for a larger version of this image.
    Figure 7: What you should see in Solution Explorer.


    Hope this helps,happy coding.

    ASP.NETArticle, Basic, Entity, Framework, Online, Silverlight, using, Visual
    ← Important Advantages Disadvantages for Linq Asp.Net C# VB
    Creating Developing Performing Silverlight 4 RIA Services Using Ajax Endpoints →

    Learn Easily Using Video Tutorials


    How to choose the right Java IDE – explained Eclipse NetBeans BlueJ

    Developing/Creating/Performing/Configuring Java Applications Using Eclipse IDE

    Step By Step Guide for Download/Install Configure Eclipse IDE for Java

    Editing data with the GridView control Asp.Net C#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Best way to prepare asp.net Interview - Success Stories

    Download Important Questions and PPT's:

    Sql Server Important Questions Online free download

    Dotnet Important Questions Online free download

    Exploring Linq to Sql Process Flow

    Learn how to perform silverlight programming

    Learn OOPs concepts in better and well manner

    Learn Ajax in better and well manner

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    *

    *


    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Enter your email address:

    Delivered by FeedBurner

    • Recent Posts

      • Bounty Huge Roll [Amazon Frustration-Free Packaging]
      • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
      • The Basic Overview of Windows Mobile Development Asp.Net C#
      • Overview of Sql server extended properties Asp.Net C#
      • How to Use Sql Server Extended properties using visual studio Asp.Net C#
    • Search by Tags!

      Application AspNet Basic between Black Bluetooth Build Business Collection Consultants Design Development Downloading effective Excel Experts Generics Implement Installing Interview Logic Management Microsoft Minutes Object Outlook Professional Programmer Programming Project Projects Questions Ready Select Server Services Silverlight Source Strings Studio Through using Visual Website Wordpress
    • Archives

      • August 2011
      • June 2011
      • May 2011
      • April 2011
      • March 2011
      • February 2011
      • December 2010
      • November 2010
      • October 2010
      • September 2010
      • August 2010
      • July 2010
      • June 2010
      • May 2010
      • April 2010
      • March 2010
      • February 2010
      • January 2010
      • December 2009
      • November 2009
      • October 2009
      • September 2009

    Copyright © 2012 NetProgrammingHelp.com

    Δ Top