(X) Hide this
    • Login
    • Join
      • Say No Bots Generate New Image
        By clicking 'Register' you accept the terms of use .

WCF RIA Services Part 1: Getting Started

(51 votes)
Brian Noyes
>
Brian Noyes
Joined Jun 10, 2010
Articles:   19
Comments:   117
More Articles
106 comments   /   posted on Jun 11, 2010
Categories:   Data Access , Line-of-Business

Tweet This!This article is Part 1 of the series WCF RIA Services.

Introduction

In order to build serious business application in Silverlight (and other client technologies), you have to work with a lot of data. And that data is usually not resident on the client machine, it is usually distributed amongst many clients and is stored and operated on by back-end services. If you try to write this kind of application architecture yourself, you have to tackle a lot of technologies and write a lot of plumbing. In the end, most of what you are doing is pushing and pulling data from the client to the back end and invoking operations on the server from the Silverlight client application. What would be great is if most of that plumbing and push-pull logic could be automated for you, allowing you to just focus on what data you need, the rules that surround the manipulation of that data, and how to present it in the client application.

This is exactly what WCF RIA Services does for you. WCF RIA Services is a new part of the .NET 4 and Silverlight 4 frameworks that lets you quickly build N-Tier Silverlight client applications without needing to focus on the service plumbing to get data into and out of your client application from back-end services, logic and data access. This article and the subsequent articles in this series will get you up and running with all the capabilities of WCF RIA Services.

RIA Services helps you to write one set of server code, but have appropriate parts of that service code available on the client without having to duplicate it or write client side code to access it. On the server side, WCF RIA Services helps you define your services, domain entities, and supporting logic. On the client side, WCF RIA Services code generates corresponding classes that let you easily call those services, have the same entities available and populated on the client side, along with supporting validation logic and other kinds of code that you can share between the client and the service side. The diagram below shows what part of your architecture WCF RIA Services focuses on.

6-9-2010 5-56-42 PM

To see this in action, in this article I’ll do a quick run through of the basics of WCF RIA Services. In subsequent articles in this series, I’ll dive into more details of what is going on under the covers and how to adapt from the simplest usage of WCF RIA Services I’ll show in this article, to more real world scenarios. In those later articles I’ll dive into things like security, validation, concurrency, customization, and combining WCF RIA Services with other practices such as the Model-View-ViewModel (MVVM) pattern and unit testing.

But first we need to cover the basics. The application I’ll be using in this series is a task and time management application. Imagine you need to be able to enter tasks for individuals, track the time they spend on those tasks, link the tasks to customers and projects and so on. Obviously there are a lot of other systems and applications that support this kind of functionality, but this will make a good, easy to understand domain for the application we will build up.

In this article we will step through the following key concepts in WCF RIA Services:

  • Project Links – A link between a Silverlight client project and a server web application or class library. The server project defines or references the domain services, entities, metadata, and shared code defined on the server side. As a result of the link, appropriate code is generated in the client project at compile time.
  • Domain Services – This is the core construct of WCF RIA Services. A domain service defines the operations supported on the server side. These are usually mostly focused on CRUD operations against entity types, but can also be arbitrary operations to be invoked on the server from the client. These operations are exposed automatically via WCF and can be called from the client generated code without needing to know much at all about WCF.
  • Entities – you define entitiy types on the server, and a client-side definition of the same entity type is generated for use on the client side. You can add validation and other kinds of metadata to the the entity definition which will affect the code generated on the client side, allowing you to just maintain a single server-side definition. The entity types on the client and server side are used to serialize and deserialize the data across the WCF service. The entity types can be created with Entity Framework, LINQ to SQL, or can be Plain Old CLR Objects (POCOs) that you define yourself.
  • Domain Context – This is the client side counterpart to the domain service. It is generated code on the client side that gives you easy access to the functionality that resides on the server side. Internally it contains a WCF proxy that makes the service calls, and it also manages creating the queries that get executed on the server side, the change tracking for the entities being manipulated on the client and more.
  • DomainDataSource – This is a data source object that can be used to execute queries and submit changes to the server side. It gets associated with the domain context and makes calls through that domain context on your behalf to query and update entities. It facilitate direct data binding from XAML or can be used behind the scenes as well.

Download the Sample Code.

Step 1: Create the Silverlight Application Project and Link to the Server Project

The application I’ll build in this series is based on a simple database that stores task and related entity information. To follow along with the steps, you will need to run the TaskManager.sql script in the download sample to create the database schema and populate it with a few sample entities. Once you have the database in place, you are ready to start creating the application. You’ll also need to have the Silverlight 4 Tools installed for Visual Studio 2010, which installs WCF RIA Services support as well.

Create a new Silverlight Application project named TasksManager. You can use WCF RIA Services with any of the Silverlight project types, including the Silverlight Business Application template that is added by WCF RIA Services itself. But to start simple, I’ll go with just the Silverlight Application template.

NewProject

After you click OK in the new project window, you will be presented with the normal dialog to create a hosting web application project. What you will see that is new is a checkbox at the bottom to Enable WCF RIA Services. Check that box to create the link between the client project and the server project so that WCF RIA Services can code generate the appropriate client code based on the domain services and entities you will create.

ProjectLink

Click OK and the projects will be created.

Step 2: Create the Domain Model Entities

WCF RIA Services is mostly about moving data back and forth between the client and server for you. So you need some data to work with. Out of the box, Entity Framework is supported best. With the WCF RIA Services Toolkit, there is also support for LINQ to SQL. And you can create your own domain services if you want to work with POCOs. For this article, you will use Entity Framework.

Right click on the TaskManager.Web server project in Solution Explorer and select Add > New Item, pick the Data category on the left, and select ADO.NET Entity Data Model, and name it TasksModel.edmx.

AddEFModel

Click Add and you will see the Entity Data Model Wizard. In the first step, leave the option to Generate from database selected and click Next. Create a New Connection in the next step to the TaskManager database you created with the sample code SQL script at the beginning.

DataConnection

The connection name should default to TaskManagerEntities, which is fine. Click Next.

In the next step, Choose Your Database Objects, check the box for Tables to select all the tables and click Finish.

DataObjects

You now have an Entity Framework data model for all the tables in the database. In this article, you will only be working with the Task table, but in future articles in the series you will work with one or two other types.

Build the solution to make sure all is well. If you forget to build after adding your entity data model, it will not show up when creating the domain service in the next step.

Step 3: Define a Domain Service

So far, the only thing specific to WCF RIA Services you have done is check the box to create the link between the client and server project. Now you will do the core activity around RIA Services: define a domain service. Right click on the TaskManager.Web project and select Add > New Item. Select the Web category, and select Domain Service Class. Name the class TasksDomainService.

AddDomainService

Next you will be presented with a dialog that lets you select a number of options for your service, including the most important option of what entities it will expose.

DomainServiceOptions

For this article, you will just be working with Tasks, so select that entity type and leave the rest of the defaults selected. I’ll be getting into more detail on some of the other options and what they do in other articles. Click OK and your domain service will be created.

Minus a bunch of comments they insert, the resulting class looks like this:

 [EnableClientAccess()]
 public class TasksDomainService : LinqToEntitiesDomainService<TaskManagerEntities>
 {
     public IQueryable<Task> GetTasks()
     {
         return this.ObjectContext.Tasks;
     }
 }

 

The LinqToEntitiesDomainService<T> class provides the glue between an entity data model and the services that will be exposed by WCF RIA Services. The EnableClientAccess attribute is what causes the client side code to be generated at compile time in the linked client project. From there, you add methods to your domain service to perform CRUD operations on the entities and possibly just expose operations that can be invoked from the client as well.

In this case, because you did not select the Enable Editing option in the previous dialog, the initial code only contains a single query method. I’ll get into more detail on the options and variations you have for query methods in the next article. But the one generated here uses convention to indicate that it is a query method based on the return type of IQueryable<T> and the method name. It just delegates to an instance of the entity data model ObjectContext that is created as a member by the base class and uses it to return all the Tasks. If you want to modify that query to order, filter, or page the results, as long as you return an IQueryable<T>, WCF RIA Services will be able to expose that as a service and generate the client code to consume it.

Rebuild the solution to make sure all is well and to generate the client side code. If you Show All Files in the TaskManager project, you will see a Generated_Code folder with a TaskManager.Web.g.cs file in it. This contains the generated code. I’ll dig into what is there in more detail in the next article.

Step 4: Retrieve Data into the UI with DomainDataSource

For this step, you will leverage the drag and drop capabilities of WCF RIA Services using hte DomainDataSource directly in the UI. In a later article I’ll discuss the MVVM pattern, why this is not the best architecture for complex applications, and how you can still leverage the DomainDataSource but do so behind the scenes in a local service.

For this article though, open MainPage.xaml in the TaskManager project. The designer will open. Open the Data Sources window (Data menu > Show Data Sources). It will take a moment the first time you open it after the client code generation, so be patient. But you should see entities for the types returned by the domain service listed in the Data Sources window.

DataSources

Drag and drop the Task entity type onto the MainPage.xaml in the designer. A DataGrid will be generated with appropriate columns for each of the properties on the entity type, and a DomainDataSource will also be declared and hooked up to the GetTasksQuery method on the TasksDomainContext class. You can drop down in the XAML and remove all the sizing and positioning properties from the DataGrid (Height, Width, HorizontalAlignment,VerticalAlignment, and Margin) so that the DataGrid fills the containing Grid.

Build and run the application. You should see something like the following.

RunningApp 

Summary

In this article, I covered the basic concepts behind a WCF RIA Services application and stepped you through the simplest possible WCF RIA Services application. You created an Entity Data Model, a RIA Services DomainService, and consumed that service in the client using the DomainDataSource and the generated TasksDomainContext. In the rest of the articles in this series, I’ll drill into more details on each aspect of WCF RIA Services, including real world application concerns of UI patterns, security, concurrency, testability, debugging and other aspects.

Download the Sample Code.

About the Author

Brian Noyes is Chief Architect of IDesign, a Microsoft Regional Director, and Connected System MVP. He is a frequent top rated speaker at conferences worldwide including Microsoft TechEd, DevConnections, DevTeach, and others. He is the author of Developing Applications with Windows Workflow Foundation, Smart Client Deployment with ClickOnce, and Data Binding in Windows Forms 2.0. Brian got started programming as a hobby while flying F-14 Tomcats in the U.S. Navy, later turning his passion for code into his current career. You can contact Brian through his blog at http://briannoyes.net.


Subscribe

Comments

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by TheRiddler on Jun 12, 2010 03:49
    Great intro article.
    Is there a timeline for other parts of the series?
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Jun 12, 2010 04:04
    At least 3 a month, should have the whole series done by end of summer.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Nen on Jun 14, 2010 08:53
    great intro, thank you, can you also include on how to unit test RIA services.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Jun 14, 2010 23:12
    Nen: That is planned for part 8.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Santosh on Jun 15, 2010 11:55
    Great Article For Starting RIA Services
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by VJ on Jun 16, 2010 15:47

    Nice tutorial! Very easy to understand.

    So how would one go about creating such a RIA service that could connect to something like CRM Dynamics?

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Jun 16, 2010 18:47

    VJ: I'll be covering that some in the next article. What you can do is create a domain service based on the DomainService base class instead of the LinqToEntities one. You an return IEnumerable<T> from query methods instead of IQueryable<T> and can do your own retrieval/update of your objects using whatever underlying API you need.

    There are a few restrictions on the parameters you can pass to your methods I'll get into in the next two installments, but you can have whatever data source you need under the covers by using POCOs and DomainService.

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Pravin on Jun 17, 2010 05:12

    Hi Brian, Good to see you in RIA space. Would you pl cover POCOs (or just presentation model) wih RIA services?

    thanks for the part 1.

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Aga on Jun 30, 2010 21:48
    Great stuff! Really easy to follow and understand!
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Cliff on Jul 13, 2010 09:03

    Quick question..
    In your grid I noticed that the Project Id, Customer Id and User Id columns are blank. I am assuming these are foreign keys to related tables in the schema.  (I have a similar scenario). How can we get those columns populated or better yet, how can I get columsn from those related tables to show up in the grid (for example Customer Name or User Name) ?

    Thanks,  Cliff.

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Shawn on Jul 21, 2010 09:19

    @Cliff:

    I just took a look at the data in the tasks table...those columns have null values in the table, and that is why they are empty in the grid.

    Getting the data to display the related info as you need would be a case of shaping your model to have the columns you want to display, and then changing your queries accordingly.

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Jul 21, 2010 17:50

    Hi Cliff - sorry for the delay in responding.

    Shawn is correct, the sample database just inserts four rows in the Task table and no related entities at this point. If you populate some related rows yourself manually, they would still not show up unless you do two things:

    - Add .Include calls to the Tasks query on the ObjectContext in the domain service to get Entity Framework to load the related entities.

    - Add [Include] attributes on the respective properties on the entity metadata class to get RIA Services to transfer those entities to the client side.

    Let me know if you have any follow on questions.

    Thanks

    Brian

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Jesper on Jul 30, 2010 17:53

    In the RIA Service Breaking changes doc it says:

    The EnableClientAccessAttribute.ServiceName property has been removed. Instead, use the ServiceContractAttribute.Name property.

     Just so you know, and can update your article if you want it up to date.

     Keep up the good work :)

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Jul 31, 2010 10:15
    Hi Jesper, thanks for the info, but I don't see where I mentioned either ServiceName or Name in my article, I am using the default attribute that just uses the type name.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Benson on Aug 17, 2010 11:08

    Really awesome ! Helped me to start with WCF RIA Services

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Mukesh on Oct 02, 2010 14:37
    Thanks a lot..
    It helped me getting started with RIA Services and actually implementing a domain service
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Venkat on Oct 07, 2010 16:15
    I want it,
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Cleyton on Oct 13, 2010 11:54

    Hi,

    I would like to congratulate you on these articles. They are fantastic. Thanks for this brillant series of articles.

    I really would like to learn how to test WCF Ria services and other stuff.

    When are you planning to finish the remaining articles?

    1. Debugging and Testing WCF RIA Services Applications
    2. Structuring WCF RIA Services Applications
    3. Exposing Additional Domain Service Endpoints for Other Clients
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Glen on Oct 13, 2010 12:07
    I am using Visual Studio 2008 with Silverlight and RIA components installed (but .Net 3). Everything went fine for me until it came to adding the data source to the page. My Data Sources window states "Your project currently has no data sources associated with it...." I tried to add one by searching for services within the solution but it did not find the domain service. Also I did not get a Generated_Code folder.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Glen on Oct 13, 2010 12:24
    I managed to set up the DomainDataSource and bind it to a DataGrid by entering the XAML code manually.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Oct 13, 2010 13:46

    Hi Cleyton,

    Sorry for the delay on the remaining three articles. Sometimes life intervenes... I hope to have the debugging and testing one out by end of October, and the remaining two by end of November.

     

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Thiru on Nov 12, 2010 16:39

    It is nice article for whom starting new wcf ria services

     

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by kiran on Nov 12, 2010 16:41
    Its very good article for wcf ria services with silverlight.........
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Ronald on Nov 25, 2010 06:55

    how to solve this:

    an unhandled exception ('unhandled error in silverlight application code:4004 categroy: managedruntimeerror

    message:

    system.servicemodel.domainservices.client.Domainoperationexception: load operation failed for query 'GetTasks'.

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Nov 25, 2010 14:41
    Ronald, you probably have a configuration problem with your connection string or the database. To know, you will need to handle the callback for the Load method, which is covered in later articles. You may want to skip ahead to the debugging part of Part 8 and come back to this one.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Peter Klein on Dec 09, 2010 23:03

    Hi Brian,

    Excellent article, where instead of simply presenting the solution as an outcome, some background is given about WHY it has to be done in a certain sequence. Thanks for that, it makes it easier to understand and reproduce in future development.

    One quesion though: after following your steps until the point where I would drag the grid from the datasources, I get the error message "Field not found: DesignProperties.DesignDataProperty". What is wrong in my approach? B.t.w. I use VB instead of C#, but no coding has been done so far...

    Best regards,

    Peter

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Dec 10, 2010 16:40
    Peter, I dont think it is anything particular to VB. I just went through the steps myself with VB and it worked fine. I have seen this error on occasion before. Make sure everything builds fine on the server and client before doing the drag drop. If that doesn't clear it, try closing Visual Studio and deleting the .suo file from the solution root folder, the \bin and \obj folders from the project directory, then open the solution, rebuild all, and see if it works then. If not, I'm not sure what the issue could be.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by ecr on Dec 15, 2010 19:33
    where can i find the next article?
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Dec 15, 2010 21:44
    Links at the top of each article.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by PUK on Dec 25, 2010 05:18

    Awesome. Just starting out in C# and SL, moving from PHP and Flex, and find articles like this invaluable.

     

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Babak on Dec 29, 2010 14:31

    Hi Brian,

    Because of this error "Field not found: DesignProperties.DesignDataProperty", I con not continue with the example. I tried all what you wrote, but it does not work.

    Babak

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Dec 29, 2010 18:18

    Babak,

    Please make sure you are not running a pre-release version of the Silverlight 4 Tools or RIA framework. See this forum post, sounds like this was a known problem in the pre-release bits, but should not be happening with the released bits. If you are sure you are on the released bits, send me a note brian.noyes AT idesign.net and I'll try to help you sort it out.

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Dec 29, 2010 18:18
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Babak on Jan 03, 2011 14:40

    Hi Brian!

    Thank you for your fast response. I updated the references in the Project und the namespaces in the .xaml file and now...it works.

    Babak

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Gopala Chintakindi on Jan 21, 2011 04:54
    Great article. I am starter and this was the perfect thing for me.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Hari Iyer on Feb 05, 2011 19:03

    HI Brian,

    I am really enjoying the series but regrettably,  I am having the same problem as Babak--ie:-File Not Found 'DesignProperties.DesignDataProperty" when dragging the Events table onto to the "Home" page.

    Please help and share the solution, Maestro!!...What references and namespaces do I need to update?

    Thanks

    Hariiyer.hari.k@gmail.com


  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Feb 05, 2011 21:57

    Hari,

    Do you happen to be in VB as well, or C#?

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Hari Iyer on Feb 06, 2011 00:23

    Brian

    I am using C#  and thanks for the quick response.-hari

    iyer.hari.k@gmail.com

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Feb 06, 2011 00:26

    Hari:

    Have you tried uninstalling Silverlight 4 Tools for Visual Studio 2010, downloading the latest, and then reinstalling the tools?

    Thanks

    Brian

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Hari Iyer on Feb 06, 2011 00:33

    Brian

    I have tried it twice.

    Hari

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Hari Iyer on Feb 08, 2011 00:59

    Hi Brian,

    I know that you are extremely busy and I regret being a nuisance newbie but any Help! (or email of someone else who has solved this problem), would be very sincerely appreciated. My dev environment is Windows 7 Ultimate, VS 2010 Professional. I have uninstall-ed and reinstalled the latest silverlight 4 and tools twice and I keep getting the same message. Field not found-' DesignProperties,DesignDataProperty'

    Thanks 
    Hari


  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Feb 08, 2011 01:26

    Hari, unfortunately I have no idea what could be wrong with your environment that would cause that. Ultimately all it is doing is some XAML code generation, so you can create the app without the drag and drop experience, but admittedly that is not the greatest answer. Do you have another machine or a virtual machine you could try on to see if it is just a single machine problem or something common to the way you are setting up your machine?

    Another thing to try to see if this is a RIA Services problem or a general visual studio one: Create an empty Silverlight Application project. Add a class to it, call it Customer or whatever. Define a couple properties on the class and make sure it is public. Compile the project. Then bring MainPage.xaml up in the designer, open the Data Sources window, click on the link or button to Add a New Data Source. Select the Object data source type, then select your Customer type from the namespace tree in the next step. After completing the wizard, you should see your customer type in the Data Sources window. Drag and drop that on the form and see if you get the same problem. If so this has nothing to do with RIA Services. If it does works, that at least isolates things to RIA Services.

    If it is isolated to RIA Services, send me your project to brian.noyes AT idesign.net so I can see if it "works on my machine". Make sure to delete the bin and obj folders of the solution projects so it doesn't get rejected by my email provider.

    Thanks, Brian

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Hari Iyer on Feb 08, 2011 01:37

    Thanks Brian,

    I will try it and let you know as soon as I have something positive to report, Appreciate all your help!!

    Warm Regards

    Hari

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Hari Iyer on Feb 10, 2011 00:00

    Brian,

    Happy ending  of sorts!! However a few observations and questions. This might be a tad bit lengthy

    The Silverlight.Web project had all the correct references for Domain Services but I had to manually add the following references to the Silverlight project 1) System.Windows.Controls, 2) System.Windows.Data, 3) System.Windows.DataInput and most importantly 4) System.Windows.Controls.DomainServices. I had to browse for this from another project because the popup window, when adding a reference,  did not show it.--- Any Thoughts??

     I am not sure why the first three did not get added automatically when the "Using System.Windows.Controls; " was present in the MainPage.xaml .cs file.-- any Thoughts?


    Lastly - I had to create the context

    <riaControls:DomainDataSource AutoLoad="True" d:DesignData ="{d:DesignInstance my:Task, CreateList=true}" Height="0" LoadedData="taskDomainDataSource_LoadedData" Name="taskDomainDataSource" QueryName="GetTasksQuery" Width="0">

                <riaControls:DomainDataSource.DomainContext>
                    <my:TaskDomainContext />
                </riaControls:DomainDataSource.DomainContext>
            </riaControls:DomainDataSource>

     and the method in the main page.xaml.cs file "private void taskDomainDataSource_LoadedData(object sender, System.Windows.Controls.LoadedDataEventArgs e)"   by copying it from your completed folder 

    Once I completed  these , I was then  able to drag and drop the "Task" table onto the design surface and run it.

    Any thoughts why the references or context  did not get added  would be appreciated. Am I missing something. Would I have to do this for every project that uses Domain Services??

    Warm Regards

    Hari

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Feb 10, 2011 18:34

    Hari:

    Everything you described doing manually is normally done automatically by VS when you do the drag drop operation, so there must be something weird about your environment. Whenever you drag and drop a control from the Toolbox, it adds the appropriate references, adds the XML namespace, and adds the element for the control. The same is true for the Data Sources window when it generates controls based on a data object being dropped. When you drop a RIA Services entity, it also adds the DomainServices.Controls library and namespace because that is what the DomainDataSource object lives in. And the XAML generation for the DDS should have declared the DomainContext as well.

    Why your machine is not doing that is more of a question for Visual Studio tech support than for me though.

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Hari Iyer on Feb 11, 2011 16:17

    Finally!! a Real Happy Ending

    Brian,

    I uninstall-ed  and  reinstalled VS 2010, Silverlight 4 and the associated (SDK and Tools) files. The Drag and Drop works as described in your article and the required references and namespaces are generated automatically..

    Once again Thanks for all your help!! and I look forward to enjoying the rest of your articles.

    Best Regards

    Hari



  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Dev on Feb 16, 2011 17:17
    Very good article. I was following this article with model first. I created empty EF Object as separated dll. I am using it in my silverlight.web project and try to create RIA Service. I am able to create RIA service using my empty model but wondering it does not display table ( as i have 2 item in that empty object). Second thing if continue with that and try to build the prj it give error like Unable to find object in metadata where as i have already added EF dll over there. It will good if someone can help me out with this.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on Feb 20, 2011 23:17
    Dev, not clear on the exact order of steps you are taking, but it shouldn't matter if you are model or database first with EF. Besides, the dialog you are referring to is a one time code generation for the domain service that really only writes a tiny bit of code for you and it is not hard to write yourself. Just create a simple domain service following the process in this article and then mimic the method patterns in your own domain service. This code is just a starting point anyway. As you will see in the later articles, you often have to modify the update/insert/delete methods to introduce business logic or to vary the query patterns.
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Mickaël on Feb 24, 2011 16:24
    Great serie of post for a newbie in Silverlight... :)
  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by FrustratedOne on May 04, 2011 14:34

    I have one thing to say about this technology.

    It's perfect... NOT!!!!!!!!!!!!!!!!!!!

    The shittiest piece of software I've ever seen.

  • -_-

    RE: WCF RIA Services Part 1: Getting Started


    posted by Brian Noyes on May 04, 2011 15:27
    FrustratedOne: Could you be more specific about what you didn't like for other's benefit?
  • iqworks

    Re: WCF RIA Services Part 1: Getting Started


    posted by iqworks on Sep 07, 2011 01:07
    I had to be sure to save and BUILD  my TaskManager.Web project after I created my taskManagerEntities object. Otherwise, when I tried to create my DomainService, I could not see the ObjectContext.
     
    After the last step when I did a BUILD and then ran the app, I got a IE page with the Tasks table column headings, but no data. I moved the cursor to each of the column titles and clicked. ONE of them caused the data to appear, cant remember which column title I clicked.

    Thanks Brian, looking forward to the other ariticles !!
  • tajnaj

    Re: WCF RIA Services Part 1: Getting Started


    posted by tajnaj on Oct 04, 2011 21:36
    Thanks ,  very helpful article
  • geertd

    Re: WCF RIA Services Part 1: Getting Started


    posted by geertd on Nov 27, 2011 17:57

    Brian,

    RIA Services are mostly used for CRUD type operations. It also supports [Invoke] operations. All types used as input/output parameters of these [Invoke] operations are generated on the client (with INotifyPropertyChanged,... interfaces implemented making them MVVM enabled).

    In my case, I don't really have CRUD alike operations (and if I would have them in a later stage, they would  not be directly related to EF but would be based on POCO's), I currently only [Invoke] operations, and the client is Silverlight only. What are the pros/cons of using RIA Services for this scenario?

    Geert.

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Nov 27, 2011 22:50

    You can definitely design your RIA domain services around POCOs, see my webcast on this subject linked in the right margin of the article.

    However, I think what you are getting at is that if your back end functionality is not focused on CRUD, is RIA Services really the right technology.

    I think there two important aspects to address here.

    The first one is that RIA services is inherently CRUD-centric, and while you can expose Invoke operations as you describe, there are limitations to the paramters types you can pass and you are losing a lot of benefit of RIA Services (i.e. CRUD - oriented query/update, change tracking, validation, etc.). So with that perspective, it would be easy to write it off as not a good fit. With POCO domain services, you could map the CRUD operations to do whatever you want, but it is still kind of putting a square peg in a round hole to use CRUD-centric operations to do more complex things.

    The other important aspect is to ask what your client platforms are. If they are only Silverlight or HTML 5 / JS, then consuming the RIA Services is not going to be a problem. If you are going to have WPF, iOS, Android, etc. clients, the consumption of RIA domain services is not as easy as consuming a REST-based HTTP service you expose yourself.

    So I generally think of using RIA Services when the app is inherently CRUD-oriented, at least for a significant number of use cases. I rarely use only RIA Services in an architecture. There are inevitably services that need multi-platform client support, or that are not a good fit for RIA Services, and so for those I put them alongside as WCF or REST based services.

    Hope that helps.

    Brian

     

  • geertd

    Re: WCF RIA Services Part 1: Getting Started


    posted by geertd on Nov 28, 2011 00:12

    Brian,

    Thanks for your advice. You interpreted my question correctly.

    I was not aware of limitations on parameter types (I will have to look deeper into this). I did a small proof of concept (to expose service methods to an mvvm SL application),  having parameter types generated with INPC implemented, including the same validation attributes (like [Required]), using X.shared.cs files to make server side custo, validation logic also available on the client...

    GeertD

  • bobby

    Re: WCF RIA Services Part 1: Getting Started


    posted by bobby on Dec 20, 2011 10:38

    Hi Brian,

    Thank you for your great series of articles.

    I am new to Silverlight and was wondering how you created your connection 'studio540.TaskManager.dbo' as shown in 'Entity Data Model Wizard'.

    I ran the script 'TaskManager.sql' successfully. When in 'Entity Data Model Wizard' i click button 'New Connection' i choose file 'TaskManager.mdf' from directory 'c:\Program Files\Microsoft Sql Server\MSSQL10_50_SQLEXPRESS\MSSQL\DATA'. I click button Ok, Next, the wizard then asks 'The connection you selected uses a local data file that is not in the current project. Would you like to copy and modify the connection?' and which I choose yes. This will add database file 'TaskManager.mdf' to App_Data directory in the 'TaskManager.web' project. I have noticed from the source code you have kindly provided it does not include database file 'TaskManager.mdf' in 'TaskManager.web' project.

    I have managed to complete successfully Part 1 to Part 7 (Authentication and Authorization) using this method.

    I would very much appreciate your help or if you could guide me to any web site.

    Bobby

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Dec 20, 2011 15:25

    Hi Bobby,

    The article does presume you have worked with database connections in Visual Studio before. Can't really give a full tutorial on that here. But instead of navigating to a mdf file, if you have the SQL Client selected as the provider, you enter a database server name and a database name (which would be TaskManager in this case) and that is all that is needed.

    This link will give you a much more detailed introduction to that part:

    http://msdn.microsoft.com/en-us/data/ff191186

    Regards

    Brian

  • pauln

    Re: WCF RIA Services Part 1: Getting Started


    posted by pauln on Dec 20, 2011 19:56

    The TasksDomainContext was never generated in my implementation when I dragged the Task entity type over.

     

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Dec 20, 2011 23:06

    Hi Pauln,

    The TasksDomainContext is not generated from a drag and drop, it is code generated at compile time. What is generated in the drag drop is a DomainDataSource, which contains an instance of the TasksDomainContext in the XAML. Are you saying it did not generate that?

    Thanks

    Brian

  • pauln

    Re: WCF RIA Services Part 1: Getting Started


    posted by pauln on Dec 20, 2011 23:19

    I recall you saying that in your article. What I ment to say is that at the end of Part 1, the TasksDomanContext is not generated anywhere in the project. After issuing the build, these three lines fail:

             TasksDomainContext context = new TasksDomainContext ();

             EntityQuery<Task> query = context.GetTasksByStartDateQuery (lowerDateVal, upperDateVal);
             LoadOperation<Task> loadOp = context.Load (query);

    with these kind of errors:

    The type or namespace name 'Task' could not be found (are you missing a using directive or an assembly reference?)

    The type or namespace name 'TasksDomainContext' could not be found (are you missing a using directive or an assembly reference?)

    The type or namespace name 'LoadOperation' could not be found (are you missing a using directive or an assembly reference?)

    The type or namespace name 'EntityQuery' could not be found (are you missing a using directive or an assembly reference?)

     

    My ultimate goal however is to be able to manipulate database values withing the code and not simply tie them to a control. Do you have any examples were a table/record can be stored in a structure where the individual records/columns can be access programmatically.

    All the examples on the internet simply show how to tie data to a xaml control for the user to see and change. I can't be the only person that needs to process the data internally.

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Dec 20, 2011 23:36
    Hard for me to say what is going on. Might want to do a diff with your server side code and the completed solution to try to see what is different. Has to be something wrong with your domain service class for it to not generate the client side types, or the link between the client and server project is not set up - check at the bottom of the project properties for the RIA Services link to see if it is set to the server project.
  • surajsv

    Re: WCF RIA Services Part 1: Getting Started


    posted by surajsv on Dec 22, 2011 09:06

    Great stuff for the beginners, but do include the CRUD operations on the grid and the details of POCO domain services

    Thanks.....

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Dec 22, 2011 15:02

    Surajsv,

    I cover the rest of the CRUD methods in later articles. For POCO domain services, see my webinar:

    http://www.silverlightshow.net/video/WCF-RIA-Services-Webinar-4.aspx

    Thanks

    Brian

  • haiyun592

    Re: WCF RIA Services Part 1: Getting Started


    posted by haiyun592 on Jan 09, 2012 18:01

    Hi Brian,

    Hot to use the following to a variable like var this_Task?

    public Task GetTask(int taskId)
    {
       return this.ObjectContext.Tasks.FirstOrDefault(t => t.TaskId == taskId);
    }

     

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Jan 10, 2012 14:53

    haiyun592,

    Not entirely clear what your question is - are you asking how to call that method if you include it in your domain service? If so, once you declare it and compile, there will be another method on the DomainContext on the client side to get a query that represents that method - GetTaskQuery. That method will take the taskId argument, and you pass it to the Load method like a query that returns a collection. You wire up a callback and when the callback fires, the argument LoadOperation<Task> will contain the resulting object. See this topic in MSDN: http://msdn.microsoft.com/en-us/library/ee707362(v=VS.91).aspx

  • haiyun592

    Re: WCF RIA Services Part 1: Getting Started


    posted by haiyun592 on Jan 11, 2012 15:46

    My question is, if the loadOp contains the resulting object, how to get a single value and assigned it to a variable, something like this:

    Suppose the method in domain service returns IQueryable<Customer>

    foreach (var rcd in loadOP)
    {
        if  (rcd.FirstName == "haiyun592")
        {
             string strFirstName = rcd.FirstName;
        }
    }

    Thanks a lot Brian!

     

  • eczimskey

    Re: WCF RIA Services Part 1: Getting Started


    posted by eczimskey on Jan 13, 2012 02:30
    Great series, Brian.  Thank you so much for de-mystifying RIA Services for us!
  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Jan 15, 2012 17:40

    haiyun592,

    You can simply use FirstOrDefault() on the Entities collection on the LoadOperations:

    private void button2_Click(object sender, RoutedEventArgs e)

    {

        TasksDomainContext context = new TasksDomainContext();

        context.Load(context.GetTaskQuery(1), OnGetTaskCompleted, context);

    }

    private void OnGetTaskCompleted(LoadOperation<Task> op)

    {

        var task = op.Entities.FirstOrDefault();

    }


  • haiyun592

    Re: WCF RIA Services Part 1: Getting Started


    posted by haiyun592 on Jan 15, 2012 22:30

    It works, thanks lot!

  • VeronicaCastaeda

    Re: WCF RIA Services Part 1: Getting Started


    posted by VeronicaCastaeda on Jan 22, 2012 09:23

    Hi. I've a  problem? I dont understand  error.

     

    System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetOviXY'. El servidor remoto devolvió un error: NotFound. ---> System.ServiceModel.CommunicationException: El servidor remoto devolvió un error: NotFound. ---> System.Net.WebException: El servidor remoto devolvió un error: NotFound. ---> System.Net.WebException: El servidor remoto devolvió un error: NotFound.   en System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)   en System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)   en System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)

    I  need help! 

     

       en System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)

       en System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

       en System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)

       --- Fin del seguimiento de la pila de excepciones internas ---

     

       en System.ServiceModel.DomainServices.Client.WebDomainClient`1.EndQueryCore(IAsyncResult asyncResult)

       en System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult)

       en System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)

     

     

     

     

     

     

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Jan 22, 2012 16:55

    If you are getting a 404 Not Found error, the only thing I can think of is that you do not have your domain service properly hosted by the web site that the Silverlight app is being launched from. It is worthwhile to fire up Fiddler and see exactly what is happening at a wire level, but since the addressing is all automatic with RIA Services, the only explanation would be if you added your domain service to a different project and did not add the right references and config information to the hosting web site.

  • manjerekarrao

    Re: WCF RIA Services Part 1: Getting Started


    posted by manjerekarrao on Jan 25, 2012 14:08

    Hi Brian,

    i created my TaskModel.edmx in a separate class library and not in TaskManager.Web server project.

    when i try adding TasksDomainService in the TaskManager.Web project, i see that the 'Generate associated classes for metadata' option is disabled. I still went ahead and added the TasksDomainService. Rebuilt the complete solution and when i finally executed the application i get this error.....

    System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetTasks'. The remote server returned an error: NotFound. ---> System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
       at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
       at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
       at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
       --- End of inner exception stack trace ---
       at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
       at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
       --- End of inner exception stack trace ---
       at System.ServiceModel.DomainServices.Client.WebDomainClient`1.EndQueryCore(IAsyncResult asyncResult)
       at System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult)
       at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
       --- End of inner exception stack trace ---

     

    Request you to pls help me in this issue.

     

    Thank you

    Manjerekar

     

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Jan 26, 2012 02:05

    Manjerekar,

    Did you add the connection string that was added to your library containing the EDMX to the hosting web.config?

  • manjerekarrao

    Re: WCF RIA Services Part 1: Getting Started


    posted by manjerekarrao on Jan 26, 2012 18:22

    Hi Brain,

    i think i might have missed adding the connection string. let me check once i'm back to office. Thank you once again.

     

    manjerekar

  • manjerekarrao

    Re: WCF RIA Services Part 1: Getting Started


    posted by manjerekarrao on Jan 29, 2012 19:51

    Hi Brain,

    but how to generate the metadata classes. it gets generated only when we have the .edmx in the 

    TaskManager.Web server project.


  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Jan 29, 2012 20:54

    Manjerekarrao,

    You can't generate the metadata class when the EDMX is in a separate file. But just look at the structure - you dont need to generate it. All you need is a partial class for your entities class with the metadata attribute on it pointing to the class that redeclares the properties for you to add metadata to. Just mimic that structure in your data library where the EDMX is. You will need to add some domainservices references to that library so that all the same attributes are available.

  • manjerekarrao

    Re: WCF RIA Services Part 1: Getting Started


    posted by manjerekarrao on Jan 30, 2012 09:21

    Hi Brain

    i've done everything you asked me to do. but still i get this error...........  :(

    System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetTasks'. The remote server returned an error: NotFound. ---> System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
       at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
       at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
       at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
       --- End of inner exception stack trace ---
       at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
       at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
       --- End of inner exception stack trace ---
       at System.ServiceModel.DomainServices.Client.WebDomainClient`1.EndQueryCore(IAsyncResult asyncResult)
       at System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult)
       at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
       --- End of inner exception stack trace ---

     

    Request you to pls help me in this issue.

     

    Thank you

    Manjerekar

  • manjerekarrao

    Re: WCF RIA Services Part 1: Getting Started


    posted by manjerekarrao on Jan 30, 2012 09:54

    Hi Brain

    i've noticed one difference between your code and my code.

    the auto generated TaskManager.Web.g.cs in the silverlight application is different from yours and mine.

    Your code:

    //------------------------------------------------------------------------------

    // <auto-generated>

    // This code was generated by a tool.

    // Runtime Version:4.0.30319.239

    //

    // Changes to this file may cause incorrect behavior and will be lost if

    // the code is regenerated.

    // </auto-generated>

    //------------------------------------------------------------------------------

     

     

     

     

    namespace

     

     

     

    TaskManager

     

    {

     

     

     

    using System;

     

     

     

     

    using System.Collections.Generic;

     

     

     

     

    using System.ComponentModel;

     

     

     

     

    using System.ComponentModel.DataAnnotations;

     

     

     

     

    using System.Linq;

     

     

     

     

    using System.ServiceModel.DomainServices;

     

     

     

     

    using System.ServiceModel.DomainServices.Client;

     

     

     

     

    using System.ServiceModel.DomainServices.Client.ApplicationServices;

     

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Context for the RIA application.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <remarks>

     

     

     

     

     

     

     

     

     

     

    /// This context extends the base to make application services and types available

     

     

     

     

     

     

     

     

     

     

    /// for consumption from code and xaml.

     

     

     

     

     

     

     

     

     

     

    /// </remarks>

     

     

     

     

     

     

     

     

     

     

    public sealed partial class WebContext : WebContextBase

     

     

     

     

     

     

     

    {

     

     

     

     

     

     

    #region

     

     

     

    Extensibility Method Definitions

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// This method is invoked from the constructor once initialization is complete and

     

     

     

     

     

     

     

     

     

     

    /// can be used for further object setup.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    partial void OnCreated();

     

     

     

     

     

     

    #endregion

     

     

     

     

     

     

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Initializes a new instance of the WebContext class.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    public WebContext()

     

    {

     

     

     

    this.OnCreated();

     

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets the context that is registered as a lifetime object with the current application.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <exception cref="InvalidOperationException"> is thrown if there is no current application,

     

     

     

     

     

     

     

     

     

     

    /// no contexts have been added, or more than one context has been added.

     

     

     

     

     

     

     

     

     

     

    /// </exception>

     

     

     

     

     

     

     

     

     

     

    /// <seealso cref="System.Windows.Application.ApplicationLifetimeObjects"/>

     

     

     

     

     

     

     

     

     

     

    public new static WebContext Current

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return ((WebContext)(WebContextBase.Current));

     

    }

    }

    }

    }

     

     

     

     

     

    namespace

     

     

     

    TaskManager.Web

     

    {

     

     

     

    using System;

     

     

     

     

    using System.Collections.Generic;

     

     

     

     

    using System.ComponentModel;

     

     

     

     

    using System.ComponentModel.DataAnnotations;

     

     

     

     

    using System.Linq;

     

     

     

     

    using System.Runtime.Serialization;

     

     

     

     

    using System.ServiceModel;

     

     

     

     

    using System.ServiceModel.DomainServices;

     

     

     

     

    using System.ServiceModel.DomainServices.Client;

     

     

     

     

    using System.ServiceModel.DomainServices.Client.ApplicationServices;

     

     

     

     

    using System.ServiceModel.Web;

     

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// The 'Task' entity class.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataContract(Namespace="http://schemas.datacontract.org/2004/07/TaskManager.Web")]

     

     

     

     

    public sealed partial class Task : Entity

     

     

     

     

     

     

     

    {

     

     

     

     

    private Nullable<int> _customerId;

     

     

     

     

     

    private string _description;

     

     

     

     

     

    private Nullable<DateTime> _endDate;

     

     

     

     

     

    private Nullable<int> _projectId;

     

     

     

     

     

    private Nullable<DateTime> _startDate;

     

     

     

     

     

    private int _taskId;

     

     

     

     

     

    private string _taskName;

     

     

     

     

     

    private Nullable<int> _userId;

     

     

     

     

     

     

     

    #region

     

     

     

    Extensibility Method Definitions

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// This method is invoked from the constructor once initialization is complete and

     

     

     

     

     

     

     

     

     

     

    /// can be used for further object setup.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    partial void OnCreated();

     

     

     

     

    partial void OnCustomerIdChanging(Nullable<int> value);

     

     

     

     

    partial void OnCustomerIdChanged();

     

     

     

     

    partial void OnDescriptionChanging(string value);

     

     

     

     

    partial void OnDescriptionChanged();

     

     

     

     

    partial void OnEndDateChanging(Nullable<DateTime> value);

     

     

     

     

    partial void OnEndDateChanged();

     

     

     

     

    partial void OnProjectIdChanging(Nullable<int> value);

     

     

     

     

    partial void OnProjectIdChanged();

     

     

     

     

    partial void OnStartDateChanging(Nullable<DateTime> value);

     

     

     

     

    partial void OnStartDateChanged();

     

     

     

     

    partial void OnTaskIdChanging(int value);

     

     

     

     

    partial void OnTaskIdChanged();

     

     

     

     

    partial void OnTaskNameChanging(string value);

     

     

     

     

    partial void OnTaskNameChanged();

     

     

     

     

    partial void OnUserIdChanging(Nullable<int> value);

     

     

     

     

    partial void OnUserIdChanged();

     

     

     

     

     

     

    #endregion

     

     

     

     

     

     

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Initializes a new instance of the <see cref="Task"/> class.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    public Task()

     

    {

     

     

     

    this.OnCreated();

     

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets or sets the 'CustomerId' value.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataMember()]

     

    [

     

     

    RoundtripOriginal()]

     

     

     

     

    public Nullable<int> CustomerId

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return this._customerId;

     

    }

     

     

     

    set

     

     

     

     

     

     

     

    {

     

     

     

    if ((this._customerId != value))

     

    {

     

     

     

    this.OnCustomerIdChanging(value);

     

     

     

     

    this.RaiseDataMemberChanging("CustomerId");

     

     

     

     

    this.ValidateProperty("CustomerId", value);

     

     

     

     

    this._customerId = value;

     

     

     

     

    this.RaiseDataMemberChanged("CustomerId");

     

     

     

     

    this.OnCustomerIdChanged();

     

    }

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets or sets the 'Description' value.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataMember()]

     

     

     

     

    public string Description

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return this._description;

     

    }

     

     

     

    set

     

     

     

     

     

     

     

    {

     

     

     

    if ((this._description != value))

     

    {

     

     

     

    this.OnDescriptionChanging(value);

     

     

     

     

    this.RaiseDataMemberChanging("Description");

     

     

     

     

    this.ValidateProperty("Description", value);

     

     

     

     

    this._description = value;

     

     

     

     

    this.RaiseDataMemberChanged("Description");

     

     

     

     

    this.OnDescriptionChanged();

     

    }

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets or sets the 'EndDate' value.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataMember()]

     

     

     

     

    public Nullable<DateTime> EndDate

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return this._endDate;

     

    }

     

     

     

    set

     

     

     

     

     

     

     

    {

     

     

     

    if ((this._endDate != value))

     

    {

     

     

     

    this.OnEndDateChanging(value);

     

     

     

     

    this.RaiseDataMemberChanging("EndDate");

     

     

     

     

    this.ValidateProperty("EndDate", value);

     

     

     

     

    this._endDate = value;

     

     

     

     

    this.RaiseDataMemberChanged("EndDate");

     

     

     

     

    this.OnEndDateChanged();

     

    }

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets or sets the 'ProjectId' value.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataMember()]

     

    [

     

     

    RoundtripOriginal()]

     

     

     

     

    public Nullable<int> ProjectId

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return this._projectId;

     

    }

     

     

     

    set

     

     

     

     

     

     

     

    {

     

     

     

    if ((this._projectId != value))

     

    {

     

     

     

    this.OnProjectIdChanging(value);

     

     

     

     

    this.RaiseDataMemberChanging("ProjectId");

     

     

     

     

    this.ValidateProperty("ProjectId", value);

     

     

     

     

    this._projectId = value;

     

     

     

     

    this.RaiseDataMemberChanged("ProjectId");

     

     

     

     

    this.OnProjectIdChanged();

     

    }

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets or sets the 'StartDate' value.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataMember()]

     

     

     

     

    public Nullable<DateTime> StartDate

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return this._startDate;

     

    }

     

     

     

    set

     

     

     

     

     

     

     

    {

     

     

     

    if ((this._startDate != value))

     

    {

     

     

     

    this.OnStartDateChanging(value);

     

     

     

     

    this.RaiseDataMemberChanging("StartDate");

     

     

     

     

    this.ValidateProperty("StartDate", value);

     

     

     

     

    this._startDate = value;

     

     

     

     

    this.RaiseDataMemberChanged("StartDate");

     

     

     

     

    this.OnStartDateChanged();

     

    }

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets or sets the 'TaskId' value.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataMember()]

     

    [

     

     

    Editable(false, AllowInitialValue=true)]

     

    [

     

     

    Key()]

     

    [

     

     

    RoundtripOriginal()]

     

     

     

     

    public int TaskId

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return this._taskId;

     

    }

     

     

     

    set

     

     

     

     

     

     

     

    {

     

     

     

    if ((this._taskId != value))

     

    {

     

     

     

    this.OnTaskIdChanging(value);

     

     

     

     

    this.ValidateProperty("TaskId", value);

     

     

     

     

    this._taskId = value;

     

     

     

     

    this.RaisePropertyChanged("TaskId");

     

     

     

     

    this.OnTaskIdChanged();

     

    }

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets or sets the 'TaskName' value.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataMember()]

     

    [

     

     

    Required()]

     

    [

     

     

    StringLength(250)]

     

     

     

     

    public string TaskName

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return this._taskName;

     

    }

     

     

     

    set

     

     

     

     

     

     

     

    {

     

     

     

    if ((this._taskName != value))

     

    {

     

     

     

    this.OnTaskNameChanging(value);

     

     

     

     

    this.RaiseDataMemberChanging("TaskName");

     

     

     

     

    this.ValidateProperty("TaskName", value);

     

     

     

     

    this._taskName = value;

     

     

     

     

    this.RaiseDataMemberChanged("TaskName");

     

     

     

     

    this.OnTaskNameChanged();

     

    }

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets or sets the 'UserId' value.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    DataMember()]

     

     

     

     

    public Nullable<int> UserId

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return this._userId;

     

    }

     

     

     

    set

     

     

     

     

     

     

     

    {

     

     

     

    if ((this._userId != value))

     

    {

     

     

     

    this.OnUserIdChanging(value);

     

     

     

     

    this.RaiseDataMemberChanging("UserId");

     

     

     

     

    this.ValidateProperty("UserId", value);

     

     

     

     

    this._userId = value;

     

     

     

     

    this.RaiseDataMemberChanged("UserId");

     

     

     

     

    this.OnUserIdChanged();

     

    }

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Computes a value from the key fields that uniquely identifies this entity instance.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <returns>An object instance that uniquely identifies this entity instance.</returns>

     

     

     

     

     

     

     

     

     

     

    public override object GetIdentity()

     

    {

     

     

     

    return this._taskId;

     

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// The DomainContext corresponding to the 'TasksDomainService' DomainService.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    public sealed partial class TasksDomainContext : DomainContext

     

     

     

     

     

     

     

    {

     

     

     

     

     

     

    #region

     

     

     

    Extensibility Method Definitions

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// This method is invoked from the constructor once initialization is complete and

     

     

     

     

     

     

     

     

     

     

    /// can be used for further object setup.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    partial void OnCreated();

     

     

     

     

     

     

    #endregion

     

     

     

     

     

     

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Initializes a new instance of the <see cref="TasksDomainContext"/> class.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    public TasksDomainContext() :

     

     

     

     

    this(new WebDomainClient<ITasksDomainServiceContract>(new Uri("TaskManager-Web-TasksDomainService.svc", UriKind.Relative)))

     

    {

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Initializes a new instance of the <see cref="TasksDomainContext"/> class with the specified service URI.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <param name="serviceUri">The TasksDomainService service URI.</param>

     

     

     

     

     

     

     

     

     

     

    public TasksDomainContext(Uri serviceUri) :

     

     

     

     

    this(new WebDomainClient<ITasksDomainServiceContract>(serviceUri))

     

    {

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Initializes a new instance of the <see cref="TasksDomainContext"/> class with the specified <paramref name="domainClient"/>.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <param name="domainClient">The DomainClient instance to use for this DomainContext.</param>

     

     

     

     

     

     

     

     

     

     

    public TasksDomainContext(DomainClient domainClient) :

     

     

     

     

    base(domainClient)

     

    {

     

     

     

    this.OnCreated();

     

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets the set of <see cref="Task"/> entity instances that have been loaded into this <see cref="TasksDomainContext"/> instance.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    public EntitySet<Task> Tasks

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return base.EntityContainer.GetEntitySet<Task>();

     

    }

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets an EntityQuery instance that can be used to load <see cref="Task"/> entity instances using the 'GetTasks' query.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Task"/> entity instances.</returns>

     

     

     

     

     

     

     

     

     

     

    public EntityQuery<Task> GetTasksQuery()

     

    {

     

     

     

    this.ValidateMethod("GetTasksQuery", null);

     

     

     

     

    return base.CreateQuery<Task>("GetTasks", null, false, true);

     

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets an EntityQuery instance that can be used to load <see cref="Task"/> entity instances using the 'GetTasksByStartDate' query.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <param name="lowerDateTimeInclusive">The value for the 'lowerDateTimeInclusive' parameter of the query.</param>

     

     

     

     

     

     

     

     

     

     

    /// <param name="upperDateTimeInclusive">The value for the 'upperDateTimeInclusive' parameter of the query.</param>

     

     

     

     

     

     

     

     

     

     

    /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Task"/> entity instances.</returns>

     

     

     

     

     

     

     

     

     

     

    public EntityQuery<Task> GetTasksByStartDateQuery(DateTime lowerDateTimeInclusive, DateTime upperDateTimeInclusive)

     

    {

     

     

     

    Dictionary<string, object> parameters = new Dictionary<string, object>();

     

    parameters.Add(

     

     

    "lowerDateTimeInclusive", lowerDateTimeInclusive);

     

    parameters.Add(

     

     

    "upperDateTimeInclusive", upperDateTimeInclusive);

     

     

     

     

    this.ValidateMethod("GetTasksByStartDateQuery", parameters);

     

     

     

     

    return base.CreateQuery<Task>("GetTasksByStartDate", parameters, false, true);

     

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Creates a new EntityContainer for this DomainContext's EntitySets.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <returns>A new container instance.</returns>

     

     

     

     

     

     

     

     

     

     

    protected override EntityContainer CreateEntityContainer()

     

    {

     

     

     

    return new TasksDomainContextEntityContainer();

     

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Service contract for the 'TasksDomainService' DomainService.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

    [

     

     

    ServiceContract()]

     

     

     

     

    public interface ITasksDomainServiceContract

     

     

     

     

     

     

     

    {

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Asynchronously invokes the 'GetTasks' operation.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <param name="callback">Callback to invoke on completion.</param>

     

     

     

     

     

     

     

     

     

     

    /// <param name="asyncState">Optional state object.</param>

     

     

     

     

     

     

     

     

     

     

    /// <returns>An IAsyncResult that can be used to monitor the request.</returns>

     

     

     

     

     

     

     

    [

     

     

    FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/TasksDomainService/GetTasksDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]

     

    [

     

     

    OperationContract(AsyncPattern=true, Action="http://tempuri.org/TasksDomainService/GetTasks", ReplyAction="http://tempuri.org/TasksDomainService/GetTasksResponse")]

     

    [

     

     

    WebGet()]

     

     

     

     

    IAsyncResult BeginGetTasks(AsyncCallback callback, object asyncState);

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Completes the asynchronous operation begun by 'BeginGetTasks'.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <param name="result">The IAsyncResult returned from 'BeginGetTasks'.</param>

     

     

     

     

     

     

     

     

     

     

    /// <returns>The 'QueryResult' returned from the 'GetTasks' operation.</returns>

     

     

     

     

     

     

     

     

     

     

    QueryResult<Task> EndGetTasks(IAsyncResult result);

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Asynchronously invokes the 'GetTasksByStartDate' operation.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <param name="lowerDateTimeInclusive">The value for the 'lowerDateTimeInclusive' parameter of this action.</param>

     

     

     

     

     

     

     

     

     

     

    /// <param name="upperDateTimeInclusive">The value for the 'upperDateTimeInclusive' parameter of this action.</param>

     

     

     

     

     

     

     

     

     

     

    /// <param name="callback">Callback to invoke on completion.</param>

     

     

     

     

     

     

     

     

     

     

    /// <param name="asyncState">Optional state object.</param>

     

     

     

     

     

     

     

     

     

     

    /// <returns>An IAsyncResult that can be used to monitor the request.</returns>

     

     

     

     

     

     

     

    [

     

     

    FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/TasksDomainService/GetTasksByStartDateDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]

     

    [

     

     

    OperationContract(AsyncPattern=true, Action="http://tempuri.org/TasksDomainService/GetTasksByStartDate", ReplyAction="http://tempuri.org/TasksDomainService/GetTasksByStartDateResponse")]

     

    [

     

     

    WebGet()]

     

     

     

     

    IAsyncResult BeginGetTasksByStartDate(DateTime lowerDateTimeInclusive, DateTime upperDateTimeInclusive, AsyncCallback callback, object asyncState);

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Completes the asynchronous operation begun by 'BeginGetTasksByStartDate'.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <param name="result">The IAsyncResult returned from 'BeginGetTasksByStartDate'.</param>

     

     

     

     

     

     

     

     

     

     

    /// <returns>The 'QueryResult' returned from the 'GetTasksByStartDate' operation.</returns>

     

     

     

     

     

     

     

     

     

     

    QueryResult<Task> EndGetTasksByStartDate(IAsyncResult result);

     

    }

     

     

     

     

    internal sealed class TasksDomainContextEntityContainer : EntityContainer

     

     

     

     

     

     

     

    {

     

     

     

     

    public TasksDomainContextEntityContainer()

     

    {

     

     

     

    this.CreateEntitySet<Task>(EntitySetOperations.None);

     

    }

    }

    }

    }

     

    My Code:

    //------------------------------------------------------------------------------

    // <auto-generated>

    // This code was generated by a tool.

    // Runtime Version:4.0.30319.239

    //

    // Changes to this file may cause incorrect behavior and will be lost if

    // the code is regenerated.

    // </auto-generated>

    //------------------------------------------------------------------------------

     

     

     

     

     

    namespace

     

     

     

    SilverlightApplication1

     

    {

     

     

     

    using System;

     

     

     

     

    using System.Collections.Generic;

     

     

     

     

    using System.ComponentModel;

     

     

     

     

    using System.ComponentModel.DataAnnotations;

     

     

     

     

    using System.Linq;

     

     

     

     

    using System.ServiceModel.DomainServices;

     

     

     

     

    using System.ServiceModel.DomainServices.Client;

     

     

     

     

    using System.ServiceModel.DomainServices.Client.ApplicationServices;

     

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Context for the RIA application.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <remarks>

     

     

     

     

     

     

     

     

     

     

    /// This context extends the base to make application services and types available

     

     

     

     

     

     

     

     

     

     

    /// for consumption from code and xaml.

     

     

     

     

     

     

     

     

     

     

    /// </remarks>

     

     

     

     

     

     

     

     

     

     

    public sealed partial class WebContext : WebContextBase

     

     

     

     

     

     

     

    {

     

     

     

     

     

     

    #region

     

     

     

    Extensibility Method Definitions

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// This method is invoked from the constructor once initialization is complete and

     

     

     

     

     

     

     

     

     

     

    /// can be used for further object setup.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    partial void OnCreated();

     

     

     

     

     

     

    #endregion

     

     

     

     

     

     

     

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Initializes a new instance of the WebContext class.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    public WebContext()

     

    {

     

     

     

    this.OnCreated();

     

    }

     

     

     

     

    /// <summary>

     

     

     

     

     

     

     

     

     

     

    /// Gets the context that is registered as a lifetime object with the current application.

     

     

     

     

     

     

     

     

     

     

    /// </summary>

     

     

     

     

     

     

     

     

     

     

    /// <exception cref="InvalidOperationException"> is thrown if there is no current application,

     

     

     

     

     

     

     

     

     

     

    /// no contexts have been added, or more than one context has been added.

     

     

     

     

     

     

     

     

     

     

    /// </exception>

     

     

     

     

     

     

     

     

     

     

    /// <seealso cref="System.Windows.Application.ApplicationLifetimeObjects"/>

     

     

     

     

     

     

     

     

     

     

    public new static WebContext Current

     

    {

     

     

     

    get

     

     

     

     

     

     

     

    {

     

     

     

    return ((WebContext)(WebContextBase.Current));

     

    }

    }

    }

    }

     

     

     

    The rest of the code is missing. probably this could be the reason.

    pls. help

    thank you

    manjerekar

     

     

     

  • manjerekarrao

    Re: WCF RIA Services Part 1: Getting Started


    posted by manjerekarrao on Jan 30, 2012 09:59
    The code is missing in both the scenario's when .edmx file is within the TaskManager.Web server project or in a separated class library.
  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Jan 30, 2012 14:20

    Afraid that code dump in comments is both inappropriate and unreadable. If you can zip up the project with no binaries in it, you can email to me at brian.noyes AT idesign.net and I will take a look.

  • BrianWatson

    Re: WCF RIA Services Part 1: Getting Started


    posted by BrianWatson on Feb 01, 2012 21:57

    Hi Brian, First let me thanks you for a great introduction to WCF RIA. I thought I would try to implement it in VB.Net but when I build at the end of step 2 I get the following error:

    Error 1 Could not load the assembly file:///P:/Silverlight/VB/TaskManager/TaskManager/obj/Debug/TaskManager.dll. This assembly may have been downloaded from the Web.  If an assembly has been downloaded from the Web, it is flagged by Windows as being a Web file, even if it resides on the local computer. This may prevent it from being used in your project. You can change this designation by changing the file properties. Only unblock assemblies that you trust. See http://go.microsoft.com/fwlink/?LinkId=179545 for more information. TaskManager

    I check and it is not blocked! Please could you give me some guidance as to what could be wrong.

    Brian Watson

  • manjerekarrao

    Re: WCF RIA Services Part 1: Getting Started


    posted by manjerekarrao on Feb 02, 2012 11:21

    Hi Brain,

    I've emailed you my project to brian.noyes@idesign.net

    request you to please look into it and help me.

     

    thank you

    manjerekar

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Feb 02, 2012 14:59

    Brian, 

    If you don't unblock the zip file before unzipping it somewhere, Windows tags the files and there is no easy way to untag them. I suggest you go back to wherever you downloaded the zip, right click on it, Properties, click the Unblock button. Then unzip it to a different location. If you try to unzip to the same location Windows will still remember the source of the original ones and you will still have this problem.

  • manjerekarrao

    Re: WCF RIA Services Part 1: Getting Started


    posted by manjerekarrao on Feb 02, 2012 15:00

    Hi Brain,

    I've emailed you my project to brian.noyes@idesign.net

    request you to please look into it and help me.

     

    thank you

    manjerekar

  • BrianWatson

    Re: WCF RIA Services Part 1: Getting Started


    posted by BrianWatson on Feb 02, 2012 17:43

    Hi Brian,

    Thank you for your speedy reply. I think I have misled you, I am not talking about anything that has been downloaded. I created the project from scratch as your article describes but using VB.Net instead of C#.

    Regards

    Brian (good name don't you think :-))

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Feb 02, 2012 19:48
    Brian, sorry for the misunderstanding. I see that error a lot with samples people have downloaded off the web in a zip file, that is why I jumped to that conclusion and didn't read your comment closely enough. I am not aware of any differences in VB that would explain this. I just stepped through it myself and it works fine in VB for me. The only thing I can speculate would cause this is if you are trying to do the development with the project on a network share or mapped network drive, that can also cause this kind of an error.
  • BrianWatson

    Re: WCF RIA Services Part 1: Getting Started


    posted by BrianWatson on Feb 03, 2012 17:28

    Hi Brian,

    Thanks again for a quick reply! You were correct in suspecting a shared drive it is a folder on my PC but was accessed via a connected share. When I opened it via the direct path all worked as it should. I don't really understand why this should be as I have full permissions both to the share and the folder. It also solved the problem I was having with another project.

    Thanks Again

    Brian Watson

     

  • RodneyRiley

    Re: WCF RIA Services Part 1: Getting Started


    posted by RodneyRiley on Mar 19, 2012 08:41
    I have multiple clients. While this makes the process much easier, I was wondering - if I wanted to develop web apps that each client could use - can I simply copy the server-side code to another directory and change the names throughout appropiately (i.e. Customer1 to Customer2)? To simplify my question, I want to be able to create a template that I can copy and change the names on the database instance and the associated calls throughout the code, compile and distribute. Is it that simple?
  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Mar 19, 2012 15:33

    Hi Rodney,

    I am unclear on the multiplicity of what you are trying to describe. Are you saying you have multiple client platforms that you want to consume your services? Are you saying you want to have multiple instances of the server side that are accessed concurrently (i.e. load balanced) by the same clients? Or are you saying you want to have multiple deployments of the service for different clients with slight variations between them, so you want to know what the minimum set of things you need to copy between server projects is?

    Thanks

    Brian

  • RodneyRiley

    Re: WCF RIA Services Part 1: Getting Started


    posted by RodneyRiley on Mar 19, 2012 17:54
    Sorry Brian. I should not have mixed terms (client being a reserved word). I have many customers. For each customer I want to have a different database instance and website. I was wondering if I had a template that I copy into Cust1.com domain and Cust2.com domain, etc then make slight modifications to the site, would that be easier that going through this structuring process for each customer.
  • RodneyRiley

    Re: WCF RIA Services Part 1: Getting Started


    posted by RodneyRiley on Mar 19, 2012 18:23
    Sorry Brian. I should not have mixed terms (client being a reserved word). I have many customers. For each customer I want to have a different database instance and website. I was wondering if I had a template that I copy into Cust1.com domain and Cust2.com domain, etc then make slight modifications to the site, would that be easier that going through this structuring process for each customer.
  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Mar 19, 2012 18:52

    So without modification you should be able to stand up multiple sites with the same code and database, even on the same server with no problem. RIA Services assumes it will find the services on the site the Silverlight app was downloaded from, so you would have vertical partitioning for each customer with the only change needed for each customer being the connection string in web.config.

    For modifications, it really depends on the scope and complexity of those changes - i.e. adding a property or a few for a given customer's objects would affect the database, the EF model, but not really anything else on the server side unless there is field specific validation rules enforced programmatically by the server. On the client side the code is all generated as far as the RIA code goes, so that would sync on build and the only changes should be in the UI elements and their bindings to the model object properties. 

    But if you are talking about bigger changes like different rules, different relations in the object model, different exposed service methods etc, you would really have to maintain multiple baselines per customer.

    RIA is built around a strongly-typed entity model architecture. If you try to build loosey-goosey architecture (http://msdn.microsoft.com/en-us/library/ms954638.aspx#soade_topic3) on topic of RIA services, you are really going to be fighting an impedance mismatch, as well as implementing a service anti-pattern.


  • RodneyRiley

    Re: WCF RIA Services Part 1: Getting Started


    posted by RodneyRiley on Mar 19, 2012 22:36

    Thanks Brian That really helps. All the sites will be the same and need the same bd support. only the names and images will change.

     

  • fardosht

    Re: WCF RIA Services Part 1: Getting Started


    posted by fardosht on Apr 25, 2012 13:53

    I’m using Oracle ODAC 11.2.0.3 and Silverlight 4 on .NET framework 4. Everything went as you describe except when I run the debug.  I keep getting the following error.  I know the problem is somewhere in the web.config but can’t tell where.  Your help is greatly appreciated.

    Regards,

    Fardosht

    ---------------------------

    Load Error

    ---------------------------

    System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetLINE'. The remote server returned an error: NotFound. ---> System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.

     at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)

     at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState)

     at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)

       --- End of inner exception stack trace ---

     at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)

     at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

     at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)

     --- End of inner exception stack trace ---

     at System.ServiceModel.DomainServices.Client.WebDomainClient`1.EndQueryCore(IAsyncResult asyncResult)

     at System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult)

    at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)

     --- End of inner exception stack trace ---

     

    ---------------------------

    The web.config

    ------------------

    <?xml version="1.0" encoding="utf-8"?>

    <!--

      For more information on how to configure your ASP.NET application, please visit

      http://go.microsoft.com/fwlink/?LinkId=169433

      -->

    <configuration>

      <system.webServer>

        <modules runAllManagedModulesForAllRequests="true">

          <add name="DomainServiceModule" preCondition="managedHandler"

            type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

        </modules>

        <validation validateIntegratedModeConfiguration="false" />

      </system.webServer>

      <system.web>

        <httpModules>

          <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

        </httpModules>

        <compilation debug="true" targetFramework="4.0">

          <assemblies>

            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

          </assemblies>

        </compilation>

      </system.web>

      <connectionStrings>

        <add name="ArasEntities" connectionString="metadata=res://*/ArasModel.csdl|res://*/ArasModel.ssdl|res://*/ArasModel.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=myTNSName;PASSWORD=myPassword;PERSIST SECURITY INFO=True;USER ID=myUserName&quot;" providerName="System.Data.EntityClient" />

      </connectionStrings>

      <system.serviceModel>

        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"

          multipleSiteBindingsEnabled="true" />

      </system.serviceModel>

    </configuration>

     

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Apr 25, 2012 15:40

    That error doesn't look like it has anything to do with RIA Services, looks more like your Oracle query is failing. You'll have to sort that out, I'm not an Oracle guy.

    "Load operation failed for query 'GetLINE'"

  • fardosht

    Re: WCF RIA Services Part 1: Getting Started


    posted by fardosht on Apr 25, 2012 16:42

    There was no modification made to the domain service.  Very simply, I drag the LINE entity from Data Source on to the page as datagrid.  But I can't debugg it.  There is a good connection.  I can build the server model without any problem.  I can even run query from the Server Explorer!?

    Thanks for a quick reply.

     

  • brian.noyes

    Re: WCF RIA Services Part 1: Getting Started


    posted by brian.noyes on Apr 25, 2012 17:00

    I would fire up Fiddler and look at the response to the initial query as the app starts up to see if it is in fact a server side error or a client side error. Based on that stack trace though it looks like the DomainDataSource is executing the Load which calls the GetLINE method in your domain service and that method is failing and getting returned to the client. But looking at the wire level with Fiddler is your best bet for determining if it is server side or client side since the query does not execute until after your domain service get method has returned (deferred execution of an expression tree) and the client side has its own layers in between that sometimes make it hard to determine where exactly the issue is.

  • fardosht

    Re: WCF RIA Services Part 1: Getting Started


    posted by fardosht on Apr 25, 2012 17:16

    There was no modification made to the domain service.  Very simply, I drag the LINE entity from Data Source on to the page as datagrid.  But I can't debugg it.  There is a good connection.  I can build the server model without any problem.  I can even run query from the Server Explorer!?

    Thanks for a quick reply.

     

  • atiour.islam

    Re: WCF RIA Services Part 1: Getting Started


    posted by atiour.islam on Oct 13, 2012 12:59

    Thank you.

  • ankitpatel00123

    Re: WCF RIA Services Part 1: Getting Started


    posted by ankitpatel00123 on Nov 21, 2012 08:27

    thanks a lot 

  • bobcolby

    Re: WCF RIA Services Part 1: Getting Started


    posted by bobcolby on Feb 23, 2013 18:06
    Thanks for a great inroduction to this technology.  You may have hooked me on it, I'll go through the next article and see.  Also, thanks for your service to our country!
  • interlacecondo

    Re: WCF RIA Services Part 1: Getting Started


    posted by interlacecondo on Mar 28, 2014 07:36
    Several buses are available near The Interlace along with shopping centers and restaurants. The Interlace is also near Mount Faber Park, the shopping, dining and entertainment hub. The Interlace for sale
  • ctowers

    Re: WCF RIA Services Part 1: Getting Started


    posted by ctowers on Apr 03, 2014 06:24
    Commonwealth Towers will be accessible via Queenstown MRT station. Commuting to the Bukit Timah Area as well as the city area is therefore very convenient. It is also near to Alexandra Central, a rare mixed commercial development which comprises of Hotels and mall shops commonwealth towers advertisement video
  • realestate

    Re: WCF RIA Services Part 1: Getting Started


    posted by realestate on Apr 10, 2014 04:27
    The largest proportion of shadow space in the first quarter was in outlying areas after the Ministry of National Development put up several floors in Jem for sub-lease. Several firms have already indicated keen interest in sub-leasing this space. thailand
  • piter1410

    Re: WCF RIA Services Part 1: Getting Started


    posted by piter1410 on Apr 14, 2014 13:00

    Hello! I just wish to give an enormous thumbs up for the nice info you've got right here on this post.  Dlatego masaż erotyczny wrocław kraków poznań invite you.

Add Comment

Login to comment:
  *      *       

From this series