1/9/10

Sample C#, Silverlight 4, WCF RIA Service Project

This project is based on the idea presented by Ian Griffiths on MSDN's Channel 9 videos series Hand On Lab Silverlight 4. Ian presented a Business Application, where users can log in and attend events. Unfortunately the project he ended up presenting is not so "Business" like. Ian spends a lot of time on out of browser techniques, Web Cams and Drag & Drop and only 7 minutes on user Authentication.

Another bad thing about his presentation, is that he only presented selecting and updating single entities in the database and not pivot tables, such as users_roles for example, which would be the case of a normalized, business database.

The project I ended up building, is not a business application, but a navigation application. I aim to incorporate user log in, user roles and authentication when Pro Business Application with Silverlight 4 gets shipped from Amazon.

In this project I explore the capabilities of the Entity Framework, Domain Service classes and WCF RIA Services.

Find the project here

I used customization of the Domain Service class produced by VS 2010:
        [Query(IsComposable = false)]
        public Attendee GetAttendee(string name, string surname, string email)
        {
            return this.ObjectContext.Attendees.SingleOrDefault(a => (a.name == name) &&     (a.surname == surname) && (a.email == email));
        }
         [Query(IsComposable = false)]
        public Event_Centers GetEventCenter(int centerPk)
        {
            return this.ObjectContext.Event_Centers.SingleOrDefault(c => c.pk == centerPk);
        }
 and also the DomainDataSource provided by RIA Services
                    <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:MyEventsCourses, CreateList=true}" Height="0" LoadedData="myEventsCoursesDomainDataSource_LoadedData" Name="myEventsCoursesDomainDataSource" QueryName="GetMyEventsCoursesQuery" Width="0">
            <riaControls:DomainDataSource.DomainContext>
                <my1:EventPlannerDomainContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>
             int selectedEvent = Convert.ToInt32(NavigationContext.QueryString["eventId"]);
            myEventsCoursesDomainDataSource.FilterDescriptors.Add(new FilterDescriptor { Operator = FilterOperator.IsEqualTo, PropertyPath = "pk", Value = selectedEvent });
 in order to represent the database entities on the UI, either in DataGrids or in Details view, as provided by VS 2010.

To overcome the problem of feeding my DataGrids with pivot tables, I used SQL Views to represent the data

The overall experience was good, although I had problems which included my Entities losing their last characters when trying to generate the ADO.NET Entity Data Model. My entity Users became User and clashed with the built in class User. I also lost Intellisence in the XAML editor when I dragged and dropped a Wrap Panel, not to mention somehow the breakpoints stopped getting hit!!!

I really hope Pro Business Application with Silverlight 4 book meets my expectations, since I haven't found anything yet talking about real Business Apps.

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου