Pages - Menu

Tuesday 30 October 2012

Facebook Shortcuts Keys For You

Facebook Shortcuts Keys For Your "Google Chrome" Web Browser

Press: "Alt+1" = To View your 'News Feed'
Press: "Alt+2" = To View your own 'Profile'.
Press: "Alt+3" = To View pop-up of 'friend requirements'.
Press: "Alt+4" = To View pop-up of Your facebook 'Messages'.
Press: "Alt+5" = To View pop-up of Your Facebook 'Notifications'.
Press: "Alt+6" = To View Your facebook 'Account Settings'.
Press: "Alt+7" = To View your facebook 'Privacy Settings'.
Press: "Alt+8" = To View your Facebook’s own profile.
Press: "Alt+9" = To Read newest Terms of Service agreement.
Press: "Alt+?"  = To Search
Press: "Alt+m" = To Compose a 'New message'.
Press:   "L"      = Like/Unlike Photos in Light Box


If you're on "Mozilla Firefox" web browser then you've to Press "Shift" along with above Facebook shortcut keys.

Press: "Shift+Alt+1" = To View your 'News Feed'
Press: "Shift+Alt+2" = To View your own 'Profile'.
Press: "Shift+Alt+3" = To View pop-up of 'friend requirements'.
Press: "Shift+Alt+4" = To View pop-up of Your facebook 'Messages'.
Press: "Shift+Alt+5" = To View pop-up of Your 'Notifications'.
Press: "Shift+Alt+6" = To View Your facebook 'Account Settings'.
Press: "Shift+Alt+7" = To View your facebook 'Privacy Settings'.
Press: "Shift+Alt+8" = To View your Facebook’s own profile.
Press: "Shift+Alt+9" = To Read newest Terms of Service agreement.
Press: "Shift+Alt+0" = To Open Facebook Help point
Press: "Shift+Alt+?" = To Search
Press: "Shift+Alt+m" = To Compose a 'New message'.


If you're on "Internet Explorer" web browser then you've to Press "Enter" along with Facebook shortcut keys of Google Chrome.

Press: "Alt+1+Enter" = To View your 'News Feed'
Press: "Alt+2+Enter" = To View your own 'Profile'.
Press: "Alt+3+Enter" = To View pop-up of 'friend requirements'.
Press: "Alt+4+Enter" = To View pop-up of Your facebook 'Messages'.
Press: "Alt+5+Enter" = To View pop-up of Your Facebook 'Notifications'.
Press: "Alt+6+Enter" = To View Your facebook 'Account Settings'.
Press: "Alt+7+Enter" = To View your facebook 'Privacy Settings'.
Press: "Alt+8+Enter" = To View your Facebook’s own profile.
Press: "Alt+9+Enter" = To Read newest Terms of Service agreement.
Press: "Alt+?+Enter" = To Search
Press: "Alt+m+Enter" = To Compose a 'New message'.
Press:     "L"             = Like/Unlike Photos in Light Box

Tuesday 25 September 2012

Introduction - What is AJAX?

AJAX, or Asynchronous JavaScript and XML, is a fancy way to use JavaScript and XML to communicate with a web server without refreshing the web page.

Why use AJAX?

There are a couple of reasons to use AJAX in lieu of the traditional form submission. The first is that it is very light weight: instead of sending all of the form information to the server and getting all of the rendered HTML back, simply send the data the server needs to process and get back only what the client needs to process. Light weight means fast. The second reason to use AJAX is because (as the logo in the link above makes clear) AJAX is cool.

Using AJAX with ASP.NET

Even though AJAX is a client side technology that uses JavaScript, the client-server interaction is very important.
Adam Vandenberg has put together a nice JavaScript wrapper for AJAX. His wrapper even does caching, although that will not be discussed here. His wrapper is used in the code examples and project files.

Using the code

There are four parts of the code that are important to look at:
  1. The HTML There are two form elements that will interact with AJAX. The input button "btn1" will invoke the AJAX code, which will make a server call and fill the select element "select1".
    <select id="select1"></select>
    <input id="btn1" value="Fill Select" type="button" <BR>       onclick="getOptions();">
  2. The JavaScript that calls the AJAX. The function getOptions() will do the main work.
    // Create the Request object (the AJAX wrapper)
    var request = new Request();
    // Change this to fit your environment
    var url = "http://localhost/ajax/";
    function getOptions()
    {
        // Call the AJAX
        // Notice the second parameter is actually a function to handle the <BR>    // response
        request.GetNoCache(url + "requests/getOptions.aspx",
        function(result)
        {
            if (result.readyState!=ReadyState.Complete)
                return;               
            if (result.status==HttpStatus.OK && result.responseText != "")
            {
                // If the request was successfull and returned data
                var vals = result.responseText.split("~");
                for (i=0; i<vals.length; i++)
                {
                    var pair = vals[i].split("|");
                    var op = new Option(pair[1], pair[0], false, false);
                    var sel = document.getElementById("select1");
                    sel.options[sel.length] = op;
                }
                alert("Remember that the new values in form" + 
                      " element 'select1' are not in viewstate." + 
                      " Code appropriately.");
            }
            else
            {
                // Handle the failure condition
                alert('Get options failed.');
            }
        }
        )
    }
  3. The ASPX file. The important thing here is that the aspx file only returns the string (XML) data from the code behind.
    <%@ Page language="c#"
                Codebehind="getOptions.aspx.cs"
                AutoEventWireup="false"
                Inherits="ajax.requests.getOptions" %>
    <%=result%>
  4. The code behind.
    protected string result = string.Empty;
    private void Page_Load(object sender, System.EventArgs e)
    {
        for (int i=0; i<10; i++)
        {
            result += i.ToString() + "|option " + i.ToString() + "~";
        }
        // to drop the last '~'
        result = result.Substring(0, result.Length - 1); <BR>}

Sunday 26 August 2012

Android and its Fragmentation


Android has been making rapid strides into the Mobile market and has become a serious contender for the top 1 position in the mobile market (and is picking up on the tablet market quite quickly).

The fact that it was anopen platform allowing for lot of innovation and choice made the developer world and the mobile OEMs vouch for it and the inroads it madeinto the market was significant – significant enough for Apple to stand up, take note and even file a law suit J

However, this very fact is now slowly turning to be a bane for the Android platform, as it has led to a huge amount of fragmentation in the market. OpenSignalMaps has done a research in 195 countries and has come up with the graphic that clearly depicts the kind of fragmentation in Android devices.

Samsung has clearly take a lion share of the market followed by HTC, Sony Ericcson and Motorola. An interesting fact is that they have spotted 3997 distinct devices!

This very fact has brought down the euphoria around Android. Another study by Appcelerator and International Data Corporation (IDC) says:

The most significant finding in the Q2 2012 Developer Survey is Apple opening a dramatic 16% lead over Google’s Android as far as which OS will win in the enterprise marketplace, with 53.2% of developers saying iOS will win vs. 37.5% saying Android will win. This is a very significant change over only three quarters: in Q3 2011, developers viewed iOS and Android in a dead heat at 44% each.
The challenges of this fragmentation are around the varied screen sizes and the many OS versions which translate to the larger effort and investment into testing on the varied combinations to keep all customers happy.
A graphic that illustrates the varied resolutions:
and the number of device models:

The above statistics sound a bit unsettling around the fragmentation aspects of Android and would probably scare away developers from investing on this platform!
But in my opinion, this is no different from the fragmentation on PC (probably better than that) where the browsers, the CPU powers, the models etc. are varied and still we have lot of gaming apps that are developed for all of them.
Probably the good news is that Android right from the beginning is learning its lessons quickly and it introduced the concept of “fragments” to scale to varied screen sizes and designs.
Android is just going through the stabilization phase of a open platform and the good news from the same study by Appelerator and IDC says:
Android has arrested its decline in developer interest. After a noticeable erosion of developer interest over the last year, developers’ Android handset “very interested” levels stabilized in Q2 2012 compared to Q1 2012, and Android tablet “very interested” levels ticked up 2.9%.

So, in my opinion, Android with all its challenges is just grown over the hype cycle and is here to stay as a strong contender to other mobile OSes and would probably win the race. However, right from the beginning, developers have to keep these variations in mind and build apps that look as seamless as possible on multiple OSes.
And testers, if you are reading, here is your chance... A lot of opportunities around device coverage, OS version coverage, screen size coverage and so on.

Multiple Ways of Programming for Android



These seem to be more than one way to program for the Android devices.

The first and the most common way is by using the Software Development Kit (SDK) using Java Syntax. This is what I have been talking about in all the earlier posts and tutorials.

The other 3 interesting ways, I believe, are:
2. Native Development Kit using C / C ++. This I am sure many are aware of and would be using to some extent. This is a little more closer to the OS, not running on top of the virtual Machine.
3. RenderScript using C99 - used to write faster graphics code like the Google Books page turn animation etc.
4. Android Scripting Layer using Python etc.

Interesting options, right?

Wednesday 4 July 2012

PHP small program

Here ,
we learn some PHP small program like sum ,display and some other...


<html>
<body>

<?php
echo "hello<br>"; //for display hello


 echo (5 + 3)."<br>";  //doing some u just change the just sign...
// display the  value
$abc=10;
echo "the value of".$abc."<br>";
printf("the value is : %d",$abc);

?>

</body>
</html>

Tuesday 3 July 2012

waiting for android small project

hi
friends in short time i will upload the small application in the android now i try to learn in the college and then i will upload the logic....

Monday 25 June 2012

Uninstalling Oracle 10g Manually from Windows XP



List of additional steps to do for cleaning the system completely after uninstall using universal installer.
# Stop any Oracle services that have been left running.


Start->Settings->Control Panel->Services
Look for any services with names starting with ‘Oracle’ and stop them.


# Run regedit and delete the following keys (some may have slightly different names in your registry):




HKEY_CURRENT_USER\SOFTWARE\ORACLE


HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet Services\EventLog\Application\Oracle.oracle


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet Services\OracleDBConsole


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet Services\Oracle10g_home


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet Services\OraclService


Note that the services control panel will still show the old services until you reboot.


# Delete the Oracle home directory
C:\Oracle


# Delete the Oracle Program Files directory:
C:\Program Files\Oracle


# Delete the Oracle Start Menu shortcuts directory:
C:\Documents and Settings\All Users\Start Menu\Programs\Oracle*

Where * indicates the name of your install. Look for and remove all Oracle directories from that location.

# Remove Oracle refereces from the path. To edit your path go to:


Start->Settings->Control Panel->System->Advanced->Environment Variables


Edit both of the environment variables user PATH and system PATH. Remove any Oracle references in them.
# Remove Oracle.DataAccess and any Polic.Oracle files from the GAC which is at:
C:\Windows\assembly\

Sunday 24 June 2012

Ways to Identify Safe Websites on the Internet


On the whole Internet, there are approximately more than 150 million active websites up and running. As a result, it often becomes a real challenge for the users to identify safe websites that are trustworthy and reputed. Have you ever wondered to know the reputation of a website before placing the order? Need to know whether a given website is child safe? Well, here are some of the ways to identify safe websites on the Web.

WOT or Web Of Trust (www.mywot.com):

WOT is a great place to test the reputation of your favorite website. WOT gives real-time ratings for every website based on the feedback that it gets from millions of trustworthy users across the globe and trusted sources, such as phishing and malware blacklists. Each domain name is evaluated based on this data and ratings are applied to them accordingly. 

In most cases, the WOT ratings are found to be highly accurate. To check the reputation of any given website, just visit www.mywot.com type-in the address of your favorite website and click on “Check now”. This tool alone can tell you a lot about the reputation and safety level of a website. However, in addition to this, I am giving you another 3 handy tools to identify safe websites on the Web.


McCafee SiteAdvisor:

McCafee SiteAdvisor is a free tool that is available as a browser add-on. It adds safety ratings to your browser and search engine results. You can download it from www.siteadvisor.com.


StopBadware:


Using this tool, you can check whether a given site is said to have involved in malware activity in the past. To check this, go to http://www.stopbadware.org/home/reportsearch and enter the URL or domain name of a website and click on “Search Clearinghouse ”. If the search does not return any result, that means the site was never involved in any of the malware activity in the past.

Google Pagerank:

Google PageRank is another great tool to check the reputation and popularity of a website. The PageRank tool rates every webpage on a scale of 1 to 10 which indicates Google’s view of importance of the page. If a given website has a PageRank of less than 3, then it is said to be less popular among the other sites on the Internet.


However, PageRank will only tell you how much popular a given website is and has nothing to do with the safety level of a website. So, this tool alone cannot be used to evaluate a website’s safety and other factors.


PageRank feature is available as a part of Google Toolbar. You can install Google Toolbar from http://www.google.com/intl/en_uk/toolbar/ie/index.html.

CAPTCHA


CAPTCHA or Captcha (pronounced as cap-ch-uh) which stands for “Completely Automated Public Turing test to tell Computers and Humans Apart” is a type of challenge-response test to ensure that the response is only generated by humans and not by a computer. In simple words, CAPTCHA is the word verification test that you will come across the end of a sign-up form while signing up for Gmail or Yahoo account. The following image shows the typical samples of CAPTCHA.
What is CAPTCHA and How it Works?


Captcha

CAPTCHA example


Almost every Internet user will have an experience of CAPTCHA in their daily Internet usage, but only a few are aware of what it is and why they are used. So in this post you will find a detailedinformation on how CAPTCHA works and why they are used.

What Purpose does CAPTCHA Exactly Serve?

CAPTCPA is mainly used to prevent automated software (bots) from performing actions on behalf of actual humans. For example while signing up for a new email account, you will come across a CAPTCHA at the end of the sign-up form so as to ensure that the form is filled out only by a legitimate human and not by any of the automated software or a computer bot. The main goal of CAPTCHA is to put forth a test which is simple and straight forward for any human to answer but for a computer, it is almost impossible to solve.


What is the Need to Create a Test that Can Tell Computers and Humans Apart?

For many the CAPTCHA may seem to be silly and annoying, but in fact it has the ability to protect systems from malicious attacks where people try to game the system. Attackers can make use of automated softwares to generate a huge quantity of requests thereby causing a high load on the target server which would degrade the quality of service of a given system, whether due to abuse or resource expenditure. This can affect millions of legitimate users and their requests. CAPTCHAscan be deployed to protect systems that are vulnerable to email spam, such as the services from Gmail, Yahoo and Hotmail.

Who Uses CAPTCHA?

CAPTCHAs are mainly used by websites that offer services like online polls and registration forms. For example, Web-based email services like Gmail, Yahoo and Hotmail offer free email accounts for their users. However upon each sign-up process, CAPTCHAs are used to prevent spammers from using a bot to generate hundreds of spam mail accounts.


Designing a CAPTCHA System

CAPTCHAs are designed on the fact that computers lack the ability that human beings have when it comes to processing visual data. It is more easily possible for humans to look at an image and pick out the patterns than a computer. This is because computers lack the real intelligence that humans have by default. CAPTCHAs are implemented by presenting users with an image which contains distorted or randomly stretched characters which only humans should be able to identify. Sometimes characters are striked out or presented with a noisy background to make it even more harder for computers to figure out the patterns.

Most, but not all, CAPTCHAs rely on a visual test. Some Websites implement a totally different CAPTCHA system to tell humans and computers apart. For example, a user is presented with 4 images in which 3 contains picture of animals and one contain a flower. The user is asked to select only those images which contain animals in them. This Turing test can easily be solved by any human, but almost impossible for a computer. 


Breaking the CAPTCHA

The challenge in breaking the CAPTCHA lies in real hard task of teaching a computer how to process information in a way similar to how humans think. Algorithms with artificial intelligence (AI) will have to be designed in order to make the computer think like humans when it comes to recognizing the patterns in images. However there is no universal algorithm that could pass through and break any CAPTCHA system and hence each CAPTCHA algorithm must have to be tackled individually. It might not work 100 percent of the time, but it can work often enough to be worthwhile to spammers.

Convert A PowerPoint 2010 Presentation Into A Video With One Click Unknown Trick




Convert A PowerPoint 2010 Presentation Into A Video With One Click Unknown Trick

Creating a video from a slideshow isn’t something new. It has been a pretty common activity thanks to the clutch of PPT to video converters. But thanks to the latest edition of Microsoft Office, you can do away with third party tools…at least for a basic video conversion job.

Microsoft Office 2010 has come in with a slew of user-friendly new features. One of the new features in PowerPoint 2010 helps you convert Powerpoint presentations to video with just a click.

Here are the steps that start with a normal presentation file.

    After creating a presentation, select the File tab from the ribbon.





Click on Save and Send – Create a Video under File Types.



A few optional settings help to further tailor your video creation process.As the screenshot below shows, you can record and time voice narration and laser pointer movements in your video effectively creating a screencast. All other animations and transitions are also preserved in the converted format.



Two dropdowns fine tune your ‘production’ for the media it will be displayed on. It also determines file size. For instance, opting for Portable devices reduces the resolution. I find this quite handy if I have to carry along and watch a presentation on an iPod or a smartphone.





You can also add the recorded timings and narration to the video. You can also specify the time that will determine the transition from one slide to the next.
Finally click on the large Create Video button and choose a location to save your video as a WMV file. 



As the conversion to .wmv format begins there will be a progress bar displayed in the lower right corner of PowerPoint that indicates the pace. The time taken for the conversion will of course depend on the size of the PowerPoint file. My 15-slide sample presentation took about eight minutes to turn into a movie.


PowerPoint 2010 supports only one video format. A few more choices like MP4, FLV etc would have been real handy. For that, you still have to depend on third-party conversion tools. Also, the highest resolution that’s on offer is 960×720. Higher resolutions (and commonly available) like 1,280×720, 1,920×1,080, or 1,920×1,080 are not available.

Make an Heart sign on Facebook and other special characters ? ? ?



Make an Heart sign on Facebook and other special characters ? ? ?

Signs like ?, ¤, ? make the typeface less monotonous. But how can you add these characters,emoticons and symbols to your status updates, comments and chatsCheck it out:


Characters by key sequences (ALT-Symbols)





For example:
Alt + 1 ☺
Alt + 2 ☻
Alt + 3 ♥
Alt + 4 ♦
Alt + 5 ♣
Alt + 6 ♠
Alt + 7 •
Alt + 8 ◘
Alt + 9 ○
Alt + 10 ◙
Alt + 11 ♂
Alt + 12 ♀
Alt + 13 ♪
Alt + 14 ♫
Alt + 15 ☼
Alt + 16 ►
Alt + 17 ◄
Alt + 18 ↕
Alt + 19 ‼
Alt + 20 ¶
Alt + 21 §
Alt + 22 ▬
Alt + 23 ↨
Alt + 24 ↑
Alt + 25 ↓
Alt + 26 →
Alt + 27 ←
Alt + 28 ∟
Alt + 29 ↔
Alt + 30 ▲
Alt + 31 ▼

Remove unwanted software during startup




Have you ever experienced that when you switch on your computer there are loads of software which come up on the screen before you can start using the computer.
For eg Yahoo Messenger,G Talk,Skype etc..just come on to the screen.Here is a simple way to remove all the unwanted software coming on the screen.

1.Click on start->run

2.Type msconfig

3.Click on startup button on top

4.Uncheck all the software you do not want to show during startup

5.Click ok and restart the computer.



Hope You all enjoyed!!

Friday 13 April 2012

or an Enterprise.

Installation

1.  Manually uninstall the following via Add/Remove programs in Control Panel:
  1. Microsoft Silverlight (any version prior to Silverlight 3 RTW)
  2. Microsoft Silverlight SDK
  3. Microsoft Silverlight Tools for Visual Studio 2008
2.  Install Visual Studio 2010 RC.
3.  Install the following:
  1. Silverlight 4 RC
  2. Silverlight 4 RC SDK
4.  Install WCF RIA Services RC.

Creating a new WCF RIA Services application

1.  Start Visual Studio
2.  On the File menu, click Newà Project. The New Project dialog is displayed.
3.  In the Project types pane, expand Visual Basic or C#, then select Silverlight.
4.  In the My Templates pane, select Silverlight Business Application.
5.  Change the project name to ‘HRApp’. Click OK.



There are a couple of things to notice once the project is created:
  1. The solution created for you consists of two projects: a Silverlight client project called HRApp and an ASP.NET Web Application server project called HRApp.Web.
  2. The default application created for you has navigation, login/logout, new user registration enabled by default. Run the project and experiment with the default, out of the box application. When running the application for the first time, allow Visual Studio to Modify Web.config file to enable debugging.
 NOTE – The default User Registration implementation requires SQL Server Express be installed on the machine.



Setting up the application

1.      In the client project, open MainPage.xaml.
2.      Notice that the default XAML code (shown below) gets the application name from a resource.

XAML
<!-- XAML --><TextBlock x:Name="ApplicationNameTextBlock"   Style="{StaticResource ApplicationNameStyle}"   Text="{Binding ApplicationStrings.ApplicationName, Source={StaticResource ResourceWrapper}}"/>
 


3.      In the client project, open the Assets folder, and in that folder open the Resources folder.
4.      Open the ApplicationStrings.resx file, and change the ApplicationName resource to “HR Application”.
5.      Save and close the ApplicationStrings.resx file.
6.      In Solution Explorer, right click the HRApp project, select Add, and then select New Item. The Add New Item dialog box is displayed.
7.       In the Categories pane, select Silverlight and in Templates pane, select Silverlight Page. Name the new item ‘EmployeeList.xaml’ and click Add.
8.       Open EmployeeList.xaml and add the following XAML code between the <Grid> tags


XAML
<!-- XAML --><ScrollViewer BorderThickness="0"  VerticalScrollBarVisibility="Auto" Padding="12,0,12,0" Margin="-12"   <StackPanel Margin="0,12,0,12" Orientation="Vertical"      <TextBlock Text="Employee List" Style="{StaticResource HeaderTextStyle}"/>    </StackPanel></ScrollViewer>

9.       Save the EmployeeList.xaml file.
10.     In Solution Explorer, click EmployeeList.xaml and drag it to the Views folder.
11.     If you are using Visual Basic, add the following Imports statement to EmployeeList.xaml.vb.


Visual Basic
Imports System.Windows.Controls

12.     Open MainPage.xaml and add a new link button to top of the page by adding the XAML code between the two existing link buttons.

XAML
<!-- XAML --><HyperlinkButton x:Name="Link3" Style="{StaticResource LinkStyle}" NavigateUri="/EmployeeList" TargetName="ContentFrame" Content="Employee List"/> <Rectangle x:Name="Divider2" Style="{StaticResource DividerStyle}"/>

13.     Run the application and you will notice a new link button (‘Employee List’) has been added.


Adding Business Logic to a .NET RIA Services application

If you have the AdventureWorks database already installed feel free to use it; otherwise you can install one from CodePlex: http://msftdbprodsamples.codeplex.com/releases/view/4004

Add a Data Source

1.      In Solution Explorer, right-click the HRApp.Web project, select Add, and then select New Item. The Add New Item dialog box is displayed.
2.      In the Categories pane, select Data, and in the Templates pane, select ADO.NET Entity Data Model. Name the data model ‘AdventureWorks.edmx’ and click Add.



3.      In the Entity Data Model Wizard, choose to generate the Model from an existing database and click Next.
4.      Select the connection to the AdventureWorks database and then set the name of the entity connection settings to AdventureWorks_DataEntities.


5.       Select Next.
6.       Expand the Tables node and choose the Employee table to be used by the Entity Data model.  Set the model namespace to ‘AdventureWorks_DataModel’.


7.       Click Finish. The entity data model appears in the designer.

8.       On the Build menu, select Build Solution.

Add a Domain Service Object and Query for Data

1.       In Solution Explorer, right-click the HRApp.Web project, select Add, and then select New Item. The Add New Item dialog box is displayed.
2.       In the Categories pane, select Web, and in the Templates pane, select Domain Service Class. Name the new item ‘OrganizationService’.


3.      Click Add
4.      In the Add New Domain Service Class dialog, select Employee from the Entities list, select Enable editing, and select Generate associated classes for metadata. Also, ensure that the Enable client access checkbox is checked.
5.       Click OK.
6.       In the OrganizationService.cs/vb file, you will see that a query method and the Create/Update/Delete (CUD) data methods have been added. The CUD data methods were added because Enable editing was selected.
7.       Customize the select function by updating the GetEmployees() method to return the data sorted by EmployeeID.
Replace this generated code:
C#Visual Basic
// C# 
public IQueryable<Employee> GetEmployees() 
{ 
return this.ObjectContext.Employees; 
} 
 
With the following code:
Visual BasicC#
'VBPublic Function GetEmployees() As IQueryable(Of Employee)    Return Me.ObjectContext.Employees.OrderBy(Function(e) e.EmployeeID)End Function
 
8.       On the Build menu, select Build Solution.
Building the solution generates the Domain Context and entities in the client project.
9.       In the client project, open EmployeeList.xaml.
10.     Open the Toolbox. The Toolbox is available from the View menu.
11.     Drag a DataGrid from the toolbox onto the XAML view for EmployeeList.xaml. Add the DataGrid inside of the StackPanel, just after the TextBlock.
Dragging a DataGrid into the XAML editor adds a reference to the System.Windows.Controls.Data assembly and maps the System.Windows.Controls namespace to a prefix. The prefix can be any value. In this walkthrough, the examples are shown with the prefix set to data.

XAML
<!-- XAML --><data:DataGrid ></data:DataGrid>

The prefix is set in the Page element.
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"

12.     Name the DataGrid  ‘dataGrid1’ , make it read-only, and set its minimum height by adding the following XAML..

XAML
<!-- XAML --><data:DataGrid Name="dataGrid1" MinHeight="100" IsReadOnly="True"></data:DataGrid>

13.     Save EmployeeList.xaml and build the solution.
14.     Open EmployeeList.xaml.cs/vb.
15.     Add the following using/Imports statements:
Visual BasicC#
'VBImports System.ServiceModel.DomainServices.Client
 
16.      In the code generated for the client project, the OrganizationContext is generated based on OrganizationService. Instantiate the OrganizationContext class and load employee data by adding the following code (in bold) to EmployeeList.xaml.cs/vb:


Visual BasicC#
'VBImports System.Windows.ControlsImports System.ServiceModel.DomainServices.ClientPartial Public Class EmployeeList    Inherits Page    Dim _OrganizationContext As New OrganizationContext    Public Sub New()        InitializeComponent()        Me.dataGrid1.ItemsSource = _OrganizationContext.Employees       _OrganizationContext.Load(_OrganizationContext.GetEmployeesQuery())End Sub    'Occurs when the user navigates to this page.    Protected Overrides Sub OnNavigatedTo(ByVal e As       System.Windows.Navigation.NavigationEventArgs)    End SubEnd Class

17.     Run the application. Click the Employee List link when the application is loaded to see the DataGrid.

Add a Custom Query

1.       In the HRApp.Web project, open  OrganizationService.cs/vb.
2.       Add a new method called GetSalariedEmployees by adding the following code to the body of the class.

Visual BasicC#
'VBPublic Function GetSalariedEmployees() As IQueryable(Of Employee)    Return Me.ObjectContext.Employees.Where(Function(e) e.SalariedFlag = True).OrderBy(Function(e) e.EmployeeID)End Function

3.       On the Build menu, select Build Solution.
4.       In the client project, open EmployeeList.xaml.cs/vb. A new query function is available in IntelliSense called OrganizationContext.GetSalariedEmployeesQuery.
5.       In the constructor, replace the call to GetEmployeesQuery() with a call to GetSalariedEmployeesQuery() .


Visual BasicC#
'VB_OrganizationContext.Load(_OrganizationContext.GetSalariedEmployeesQuery())

6.       Run the application and click the Employee List link. Notice that employees 1, 2, and 4 no longer appear in the list because they are not salaried.


Add a Domain Data Source

1.       In the client project, open EmployeeList.xaml.
2.       Drag the DomainDataSource from the toolbox onto EmployeeList.xaml, just before the DataGrid.
3.       Change the namespace prefix for System.Windows.Controls from my to riaControls.

XAML
xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"

4.       For C# solutions, add the following namespace declaration to the XAML file:

XAML
<!— XAML for C# solutions -->xmlns:ds="clr-namespace:HRApp.Web"
 

For VB solutions, add the following namespace declaration to the XAML file:

XAML
<!-- XAML for VB solutions-->xmlns:ds="clr-namespace:HRApp"

5.       Name the DomainDataSource ‘employeeDataSource’  and set the DomainContext , LoadSize, AutoLoad, and query method by adding the following XAML code:

XAML
<!-- XAML -->    <riaControls:DomainDataSource Name="employeeDataSource" LoadSize="20" QueryName="GetSalariedEmployees" AutoLoad="True"></riaControls:DomainDataSource>
 
6.       Set the DomainContext for the DomainDataSource with the following XAML code.

XAML
<!-- XAML --><riaControls:DomainDataSource Name="employeeDataSource" LoadSize="20" QueryName="GetSalariedEmployees" AutoLoad="True"    <riaControls:DomainDataSource.DomainContext     <ds:OrganizationContext/>     </riaControls:DomainDataSource.DomainContext></riaControls:DomainDataSource>

7.       Replace this DataGrid XAML:

XAML
<!-- XAML --><data:DataGrid Name="dataGrid1" MinHeight="100" IsReadOnly="True"></data:DataGrid>

with the following XAML:


XAML
<!-- XAML --><data:DataGrid Name="dataGrid1" MinHeight="100" IsReadOnly="True" Height="Auto" ItemsSource="{Binding Data, ElementName=employeeDataSource}" />

8.       Open EmployeeList.xaml.cs/vb.
9.       In the constructor, remove or comment out the code to instantiate the OrganizationContext instance, the call to GetSalariedEmployeesQuery(), and the code to set the DataGrid's ItemsSource.
You no longer need to explicitly load data, since the DomainDataSource will do this automatically.

Visual BasicC#
'VBPartial Public Class EmployeeList    Inherits Page    'Dim _OrganizationContext As New OrganizationContext    Public Sub New()        InitializeComponent()            '_OrganizationContext.Load(_OrganizationContext.GetSalariedEmployeeQuery())        'Me.dataGrid1.ItemsSource = _OrganizationContext.Employees    End Sub

10.     Run the application and click the Employee List link. The application works as before.

Add Sorting/Filtering/Paging to the DataSource

1.       Specify how data is sorted in the DataGrid by adding SortDescriptors to the DomainDataSource. Add the following XAML (in bold) to the DomainDataSource to sort the VacationHours column in Ascending order.

XAML
<!-- XAML --><riaControls:DomainDataSource Name="employeeDataSource" LoadSize="20" QueryName="GetSalariedEmployees" AutoLoad="True"  <riaControls:DomainDataSource.DomainContext   <ds:OrganizationContext/>   </riaControls:DomainDataSource.DomainContext>  <riaControls:DomainDataSource.SortDescriptors>    <riaControls:SortDescriptor PropertyPath="VacationHours" Direction="Ascending" />  </riaControls:DomainDataSource.SortDescriptors></riaControls:DomainDataSource>

2.       Run the application and click the Employee List link. The data will be sorted by Vacation Hours and you can change the sort direction by clicking on the column header.
3.       Add the XAML code in bold below to EmployeeList.xaml. That will add support for filtering.

XAML
<!-- XAML --><navigation:Page x:Class="HRApp.EmployeeList"      xmlns:ds="clr-namespace:HRApp.Web"      xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"       xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"      mc:Ignorable="d"      xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"      d:DesignWidth="640" d:DesignHeight="480"      Title="EmployeeList Page"><Grid x:Name="LayoutRoot" Background="White"><ScrollViewer BorderThickness="0"  VerticalScrollBarVisibility="Auto" Padding="12,0,12,0" Margin="-12" <StackPanel Margin="0,12,0,12" Orientation="Vertical"    <TextBlock Text="Employee List" Style="{StaticResource HeaderTextStyle}"/>      <StackPanel Orientation="Horizontal"                   HorizontalAlignment="Right"                   Margin="0,-16,0,0"        <TextBlock VerticalAlignment="Center"                     Text="Min Vacation Hours Filter" />         <TextBox x:Name="vacationHoursText" Width="75"                   FontSize="11" Margin="4" Text="0"/>      </StackPanel>      <riaControls:DomainDataSource             Name="employeeDataSource"             LoadSize="20"             QueryName="GetSalariedEmployees"             AutoLoad="True"       <riaControls:DomainDataSource.DomainContext         <ds:OrganizationContext/>         </riaControls:DomainDataSource.DomainContext>        <riaControls:DomainDataSource.SortDescriptors>          <riaControls:SortDescriptor PropertyPath="VacationHours"                                   Direction="Ascending" />        </riaControls:DomainDataSource.SortDescriptors>       <riaControls:DomainDataSource.FilterDescriptors>         <riaControls:FilterDescriptor               PropertyPath="VacationHours"               Operator="IsGreaterThanOrEqualTo"              IgnoredValue=""              Value="{Binding ElementName=vacationHoursText, Path=Text}"  >         </riaControls:FilterDescriptor>       </riaControls:DomainDataSource.FilterDescriptors>      </riaControls:DomainDataSource>      <data:DataGrid MinHeight="100"                IsReadOnly="True"                ItemsSource="{Binding Data, ElementName=employeeDataSource}"               Name="dataGrid1" />  </StackPanel></ScrollViewer>        </Grid></navigation:Page>

4.       Run the Application and filter the Employee List using the “Min Vacation Hours Filter” Text Box


5.       Drag a DataPager from the toolbox on to EmployeeList.xaml. Add the DataPager just below the DataGrid.
6.       Set the page size to 5 and set the source by adding the following XAML to the DataPager:

XAML
<!-- XAML --><br><br><data:DataPager PageSize="5" Source="{Binding Data, ElementName=employeeDataSource}" Margin="0,-1,0,0"></data:DataPager><br>

7.       Run the application and click the employee list link. You will see only 5 rows of filtered data per page and pager controls below the DataGrid.


Master Detail

Adding a DataForm

We will be using the DataForm Control from the SL 3 Toolkit for the Detail View. The Silverlight Business Application Project Template carries the System.Windows.Controls.Data.DataForm.Toolkit.dll binary in the ‘Libs’ Folder, hence our Project already has access to the DataForm Control.

1.       In the client project, open EmployeeList.xaml.
2.       Add the following namespace declaration to EmployeeList.xaml.

XAML
<!-- XAML --> 
 
xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 

3.       After the DataPager control, add the XAML code below. The code adds the DataForm to the EmployeeList Page and sets the DataForm attributes and specifies the columns to be displayed.

<dataForm:DataForm x:Name="dataForm1" Header="Employee Information"  AutoGenerateFields="False" AutoEdit="False" AutoCommit="False" CurrentItem="{Binding SelectedItem, ElementName=dataGrid1}" Margin="0,12,0,0">
<dataForm:DataForm.EditTemplate>
  <DataTemplate>
<StackPanel>
<dataForm:DataField Label="Employee ID">
                        <TextBox IsReadOnly="True"
                              Text="{Binding EmployeeID, Mode=OneWay}" />
                      </dataForm:DataField>
                      <dataForm:DataField Label="Login ID">
                           <TextBox Text="{Binding LoginID, Mode=TwoWay}" />
                      </dataForm:DataField>
                      <dataForm:DataField Label="Hire Date">
                           <TextBox Text="{Binding HireDate, Mode=TwoWay}" />
                      </dataForm:DataField>
                      <dataForm:DataField Label="Marital Status">
                           <TextBox Text="{Binding MaritalStatus, Mode=TwoWay}" />
                      </dataForm:DataField>
                      <dataForm:DataField Label="Gender">
                           <TextBox Text="{Binding Gender, Mode=TwoWay,NotifyOnValidationError=True,  ValidatesOnExceptions=True }"  />
                      </dataForm:DataField>
                      <dataForm:DataField Label="Vacation Hours">
                           <TextBox Text="{Binding VacationHours, Mode=TwoWay,NotifyOnValidationError=True,  ValidatesOnExceptions=True }"  />
                      </dataForm:DataField>
                      <dataForm:DataField Label="Sick Leave Hours">
                           <TextBox Text="{Binding SickLeaveHours, Mode=TwoWay,NotifyOnValidationError=True,  ValidatesOnExceptions=True }"  />
                      </dataForm:DataField>
                      <dataForm:DataField Label="Active">
                           <CheckBox IsChecked="{Binding CurrentFlag, Mode=TwoWay,NotifyOnValidationError=True,  ValidatesOnExceptions=True }"  />
                      </dataForm:DataField>
              </StackPanel>
         </DataTemplate>
   </dataForm:DataForm.EditTemplate>
</dataForm:DataForm>

4.       Run the application and click the employee list link. The DataForm displays details of the item selected in the DataGrid.


Updating the Database

Updating a record

Checking the Enable editing option in the New Domain Service Class wizard caused CUD methods to be generated automatically in the domain service layer (OrganizationService class). In order to use these methods to update the database, you will add editing buttons to the user interface of the employee list.
1.       In the client project, open EmployeeList.xaml.
Add a ‘Submit’ button just after the DataForm tags by adding the following XAML code.

XAML
<!-- XAML --> 
 
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0"  <Button x:Name="submitButton" Width="75" Height="23"   
          Content="Submit" Margin="4,0,0,0" Click="submitButton_Click"/> 
                 
</StackPanel> 

3.       Handle the button click event in EmployeeList.xaml.cs/vb by adding the following code:

Visual BasicC#
'VB 
Private Sub submitButton_Click(ByVal sender As System.ObjectByVal e As System.Windows.RoutedEventArgs) 
    employeeDataSource.SubmitChanges() 
End Sub 
 

4.        Run the application and click the Employee List link. You can now modify any editable field by clicking on the pencil icon on the DataForm to put the form in edit mode. Make changes to the Employee data and click OK when done with the edits. Click the Submit button to save the data. Changes are saved to the database on the server only when you click the ‘Submit’ button.

Adding Custom Methods to a Domain Service

1.       In the HRApp.Web server project, open OrganizationService.cs/vb and add a custom method called ‘ApproveSabbatical’.

Visual BasicC#
'VB 
    Public Sub ApproveSabbatical(ByVal current As Employee) 
        Me.ObjectContext.Employees.AttachAsModified(current) 
        current.CurrentFlag = False 
    End Sub 

2.       On the Build menu, select Build Solution.
3.       In the client project, open EmployeeList.xaml.
4.       Add an ‘Approve Sabbatical’ button by adding the following XAML code (in bold):


XAML
<!-- XAML --> 
 
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0"                <Button x:Name="submitButton" Width="75" Height="23"  Content="Save"  Margin="4,0,0,0" Click="submitButton_Click"/> 
                <Button x:Name="approveSabbatical" Width="115" Height="23"  Content="Approve Sabbatical"  Margin="4,0,0,0" Click="approveSabbatical_Click"/> 
            </StackPanel> 

5.       Open EmployeeList.xaml.cs/vb.
6.       Handle the button click event  and call the ApproveSabbatical method by adding the following code:

Visual BasicC#
'VB 
Private Sub approveSabbatical_Click(ByVal sender As System.ObjectByVal e As System.Windows.RoutedEventArgs) 
    Dim luckyEmployee As Employee 
    luckyEmployee = dataGrid1.SelectedItem 
    luckyEmployee.ApproveSabbatical() 
    employeeDataSource.SubmitChanges() 
End Sub 
 
7.        Run the application and click the employee list link. Click the ApproveSabbatical button and note that the CurrentFlag for the selected employee clears.

Validation

Basic Validation

The DataForm control has the ability to show validation errors that come from the Data Access Layer (DAL). For example, enter a non-integer value in the Vacation Hours field in the detail view and a validation error is displayed.


Checking the Generate associated classes for metadata option in the New Domain Service Class wizard caused a file named OrganizationService.metadata.cs/vb to be generated automatically in the HRApp.Web project. You will add validation attributes to this file that will be enforced across application tiers.
1.       In the HRApp.web project, open OrganizationService.metadata.cs/vb.
2.       Add the following attributes to Gender and Vacation Hours:

Visual BasicC#
'VB 
<Required()> _ 
Public Gender As String 
 
<Range(070)> _ 
Public VacationHours As Short 

3.      On the Build menu, select Build Solution.
4.      Run the application.
5.      Click on the Employee List link. Select an employee and click the pencil icon in the upper right hand corner of the data form to enable editing. Enter a value into the Vacation Hours field that is not within the valid range (0-70). You will see a validation error. Also note that the Gender field is required and cannot be left empty.

Custom Validation

1.       In Solution Explorer, right-click the HRApp.Web project, select Add, and then select New Item. The Add New Item dialog box is displayed.
2.       In the Categories pane, select Code, and in the Templates pane, select Code File. Name the new item ‘OrganizationService.shared.cs’ or ‘OrganizationService.shared.vb’ and click Add.
3.       Add the following block of code to the file:

Visual BasicC#
'VB 
Imports System 
Imports System.ComponentModel.DataAnnotations 
 
Public Module GenderValidator 
    Public Function IsGenderValid(ByVal gender As StringByVal context As ValidationContext) As ValidationResult 
        If gender = "M" OrElse gender = "m" OrElse gender = "F" OrElse gender = "f" Then 
            Return ValidationResult.Success 
        Else 
            Return New ValidationResult("The Gender field only has two valid values 'M'/'F'"New String() {"Gender"}) 
        End If 
    End Function 
End Module 

Note: Since the file ends with ‘.shared.cs/vb’, the same code will be available to be consumed on the client as well as the server. We will be using this to run the same validation rule at both locations. (After you rebuild the solution, look in the hidden Generated_Code folder on the client, and you will see the OrganizationService.shared.cs/vb file present there as well and being compiled as part of the server project.)
4.       Open OrganizationService.metadata.cs/vb.
5.       Add a new custom validation attribute to the gender property by adding the following code (in bold).

Visual BasicC#
'VB 
<Required()> _ 
<CustomValidation(GetType(GenderValidator), "IsGenderValid")> _ 
Public Gender As String 

6.       On the Build menu, select Build Solution.
7.       Run the application.
8.       Click on the Employee List link. Enter a value for the Gender field that is not ’M’ or ’F’.


Add a new record

You will now create a user interface to allow the addition of new employee records to the database. The validation rules that you added in the previous sections will automatically be applied in the new user interface.
1.       In Solution Explorer, right-click the HRApp project, select Add, and then select New Item. The Add New Item dialog box is displayed.
2.       In the Categories pane, select Silverlight, and in the Templates pane, select Silverlight Child Window. Name the new item ‘EmployeeRegistrationWindow.xaml’ and click Add.

3.       Open EmployeeRegistrationWindow.xaml.cs/vb and add the following using/Imports statement:

JavaScriptC#
'VB 
Imports System.Windows.Controls 
Imports System.Windows 

4.       Add the following property in the code:

Visual BasicC#
'VB 
Public Property NewEmployee As Employee 

5.       Open EmployeeRegistrationWindow.xaml.
6.       Hide the ChildWindow Close button by adding the XAML in bold below.
<controls:ChildWindow x:Class="HRApp.EmployeeRegistrationWindow"
           …
           Width="400" Height="300"
           Title="EmployeeRegistrationWindow" HasCloseButton="False">
7.       As we did for the Details view, here too we will be using the DataForm Control from the SL 3 Toolkit. The Silverlight Business Application Project Template carries the System.Windows.Controls.Data.DataForm.Toolkit binary in the ‘Libs’ Folder, hence our Project already has access to the DataForm Control.
Add the following namespace declaration to EmployeeRegistrationWindow.xaml:

XAML
<!-- XAML --> 
 
xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
 

8.       Add the DataForm from to the EmployeeRegistrationWindow.xaml just above the ‘Cancel’ button using the XAML Code below.

<dataForm:DataForm x:Name="addEmployeeDataForm"   AutoGenerateFields="False" AutoCommit="True" AutoEdit="True" CommandButtonsVisibility="None">
            <dataForm:DataForm.EditTemplate>
                <DataTemplate>
                    <StackPanel>
                        <dataForm:DataField Label="Login ID">
                            <TextBox Text="{Binding LoginID, Mode=TwoWay}" />
                        </dataForm:DataField>
                        <dataForm:DataField Label="National ID">
                            <TextBox Text="{Binding NationalIDNumber, Mode=TwoWay}" />
                        </dataForm:DataField>
                        <dataForm:DataField Label="Title">
                            <TextBox Text="{Binding Title, Mode=TwoWay}" />
                        </dataForm:DataField>
                        <dataForm:DataField Label="Marital Status">
                            <TextBox Text="{Binding MaritalStatus, Mode=TwoWay}" />
                        </dataForm:DataField>
                        <dataForm:DataField Label="Gender">
                            <TextBox Text="{Binding Gender, Mode=TwoWay,NotifyOnValidationError=True,  ValidatesOnExceptions=True }" />
                        </dataForm:DataField>
                        <dataForm:DataField Label="Salaried">
                            <CheckBox IsChecked="{Binding SalariedFlag, Mode=TwoWay,NotifyOnValidationError=True,  ValidatesOnExceptions=True }" />
                        </dataForm:DataField>
                        <dataForm:DataField Label="Active">
                            <CheckBox IsChecked="{Binding CurrentFlag, Mode=TwoWay,NotifyOnValidationError=True,  ValidatesOnExceptions=True }" />
                        </dataForm:DataField>
                    </StackPanel>
                </DataTemplate>
            </dataForm:DataForm.EditTemplate>
        </dataForm:DataForm>

9.       Open EmployeeRegistrationWindow.xaml.cs/vb and add the following code (in bold):

JavaScriptC#
'VB 
Partial Public Class EmployeeRegistrationWindow 
    Inherits ChildWindow 
 
    Public Sub New() 
        InitializeComponent() 
        NewEmployee = New Employee 
        addEmployeeDataForm.CurrentItem = NewEmployee 
        addEmployeeDataForm.BeginEdit() 
    End Sub 
 
    Public Property NewEmployee As Employee 
 
    Private Sub OKButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles OKButton.Click 
        Me.addEmployeeDataForm.CommitEdit() 
        Me.DialogResult = True 
    End Sub 
 
    Private Sub CancelButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles CancelButton.Click 
        NewEmployee = Nothing 
        addEmployeeDataForm.CancelEdit() 
        Me.DialogResult = False 
    End Sub 
 
End Class 

10.       Open EmployeeList.xaml.
11.        Add a button called ‘addNewEmployee’ between the DataPager and the DataForm by adding the following XAML code.

XAML
<!-- XAML --> 
 
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0"    <Button x:Name="addNewEmployee" Width="90" Height="23"  Content="Add Employee"  Margin="4,0,0,0" Click="addNewEmployee_Click"/> 
</StackPanel> 

12.       Open EmployeeList.xaml.cs/vb.
13.        Handle the button click event to show the EmployeeRegistrationWindow by adding the following code:

Visual BasicC#
'VB 
Private Sub addNewEmployee_Click(ByVal sender As System.ObjectByVal e As System.Windows.RoutedEventArgs) 
    Dim addEmp As New EmployeeRegistrationWindow() 
    AddHandler addEmp.Closed, AddressOf addEmp_Closed 
    addEmp.Show() 
End Sub 

14.       Add the following method to handle the closed event for the EmployeeRegistrationWindow:

Visual BasicC#
'VB 
Private Sub addEmp_Closed(ByVal sender As ObjectByVal e As System.EventArgs) 
    Dim emp As EmployeeRegistrationWindow = sender 
    If Not emp.NewEmployee Is Nothing Then 
        Dim _OrganizationContext As OrganizationContext = employeeDataSource.DomainContext 
        _OrganizationContext.Employees.Add(emp.NewEmployee) 
        employeeDataSource.SubmitChanges() 
    End If 
End Sub 

15.       In the HRApp.web project, open OrganizationService.cs/vb.
16.       Add the following code (in bold) to the InsertEmployee method:

Visual BasicC#
'VB 
Public Sub InsertEmployee(ByVal employee As Employee) 
    'Modify the employee data to meet the database constraints. 
    employee.HireDate = DateTime.Now 
    employee.ModifiedDate = DateTime.Now 
    employee.VacationHours = 0 
    employee.SickLeaveHours = 0 
    employee.rowguid = Guid.NewGuid() 
    employee.ContactID = 1001 
    employee.BirthDate = New DateTime(1967318) 
 
    If ((employee.EntityState = EntityState.Detached) = FalseThen 
        Me.ObjectContext.ObjectStateManager.ChangeObjectState(employee, EntityState.Added) 
    Else 
        Me.ObjectContext.Employees.AddObject(employee) 
    End If 
 
End Sub 

17.       Run the application.
18.       Click the employee list link. You can now add new employees to the database by clicking the ‘Add Employee’ button. To ensure that the new employee appears in the list, mark the employee as Salaried. Earlier you modified the application to only load salaried employees.


Authentication

Authentication

1.       Open OrganizationService.cs/vb
2.       Add the RequiresAuthentication attribute on the ApproveSabbatical method by adding the following code (in bold).
This ensures that only authenticated users can now call the ApproveSabbatical method on the server. If an anonymous user clicks on the ApproveSabbatical button, the CurrentFlag for the selected employee will not be cleared.

Visual BasicC#
'VB 
<RequiresAuthentication()> _ 
Public Sub ApproveSabbatical(ByVal current As Employee) 
    Me.ObjectContext.Employees.AttachAsModified(current) 
    current.CurrentFlag = False 
End Sub 

3.       In the client project, open EmployeeList.xaml.cs/vb.
4.       Add the following using/Imports statements:

Visual BasicC#
'VB  
Imports System.ServiceModel.DomainServices.Client.ApplicationServices 

5.       Modify the approveSabbatical_Click method with the following code: This will allow anonymous users to get authenticated and then approve a sabbatical. If the users do not have an existing user account they can create one using the Registration Dialog.

Visual BasicC#
'VB 
    Private Sub approveSabbatical_Click(ByVal sender As ObjectByVal e As System.Windows.RoutedEventArgs) 
        If WebContext.Current.User IsNot Nothing AndAlso WebContext.Current.User.IsAuthenticated Then 
            Dim luckyEmployee As Employee = dataGrid1.SelectedItem 
            luckyEmployee.ApproveSabbatical() 
            employeeDataSource.SubmitChanges() 
        Else 
            AddHandler WebContext.Current.Authentication.LoggedIn, AddressOf Current_LoginCompleted 
            Dim newWindow As New LoginRegistrationWindow 
            newWindow.Show() 
        End If 
    End Sub 
 
    Private Sub Current_LoginCompleted(ByVal sender As ObjectByVal e As AuthenticationEventArgs) 
        Dim luckyEmployee As Employee = dataGrid1.SelectedItem 
        luckyEmployee.ApproveSabbatical() 
        employeeDataSource.SubmitChanges() 
        RemoveHandler WebContext.Current.Authentication.LoggedIn, AddressOf Current_LoginCompleted 
    End Sub 

6.       Run the application and click the employee list link.
7.       Select an employee record and click the ‘Approve Sabbatical’ button. You are redirected to the login page.
8.       Enter your credentials to login, or click register.
After login is completed, you are redirected to the Employee List page and the employee’s sabbatical is approved.


Completed Projects

The completed projects for both VB and C# can be found at:-
http://go.microsoft.com/fwlink/?LinkId=145481


WCF RIA Services

Microsoft WCF RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms using WCF. The RIA Services provides a prescriptive pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes and custom operations. It also provides end-to-end support for common tasks such as data validation, authentication and roles by integrating with Silverlight components on the client and ASP.NET on the mid-tier. It includes rich tooling for integrating client and mid-tier projects and for building rich UI through the simplicity of drag-drop support.

For the latest information please click here .

RIA Services Home Page with links to the download site, MSDN docs, talks ... can be found here.

For help porting applications to the latest bits - Breaking Changes from Beta(PDC 09) to RTW

The document above also insludes guidance on updating VS 2008/.NET 3.5 RIA Services applications to VS 2010/.NET 4
Please use the forums to provide feedback or post questions.