Windows Scripting
  Home arrow Windows Scripting arrow Page 5 - Designing WCF DataContract Classes Using t...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Designing WCF DataContract Classes Using the LINQ to SQL Designer
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2009-01-14

    Table of Contents:
  • Designing WCF DataContract Classes Using the LINQ to SQL Designer
  • Creating WCF DataContract classes visually using LINQ to SQL Designer
  • Creating WCF DataContract classes visually using LINQ to SQL Designer: Accessing in Silverlight
  • Inheriting WCF DataContract classes visually using LINQ to SQL Designer
  • Inheriting WCF DataContract classes visually using the LINQ to SQL Designer: accessing

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Designing WCF DataContract Classes Using the LINQ to SQL Designer - Inheriting WCF DataContract classes visually using the LINQ to SQL Designer: accessing


    (Page 5 of 5 )

    In the previous section, we saw how we can inherit existing "DataContract" classes easily using the LINQ to SQL Designer. Now, we need to have this show up in a Silverlight application.

    Modify IEmpService.vb so that it looks like the following:


    <ServiceContract()> _

    Public Interface IEmpService


    <OperationContract()> _

    Function GetEnameDname() As List(Of EnameDname)


    <OperationContract()> _

    Function GetEnameDnameSal() As List(Of EnameDnameSal)


    End Interface


    Add a new method to EmpService.vb as follows:


    Public Function GetEnameDnameSal() As System.Collections.Generic.List(Of EnameDnameSal) Implements IEmpService.GetEnameDnameSal

    Using ctxt As New DemoEmpDataContext

    ctxt.ObjectTrackingEnabled = False

    Return (From p In ctxt.Emps _

    Select New EnameDnameSal With {.Ename = p.Ename, .Dname = p.Dept.Dname, .Sal = p.Sal}).ToList

    End Using

    End Function


    Modify the existing markup so that it looks like the following:


    <UserControl x:Class="DemoSL.Page5"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Width="400" Height="300" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data">

     <StackPanel Height="Auto" HorizontalAlignment="Stretch" x:Name="LayoutRoot" VerticalAlignment="Stretch" Background="White" Orientation="Vertical">

     <Button Height="27" HorizontalAlignment="Left" x:Name="btnShow" Width="80" Content="Show"/>

     <Button Height="27" HorizontalAlignment="Left" x:Name="btnShowSalAlso" Width="90" Content="Show Sal Also"/>

     <TextBlock Height="26" HorizontalAlignment="Left" x:Name="lblMsg" Width="350" Text="" TextWrapping="Wrap"/>

     <ScrollViewer Height="243" HorizontalAlignment="Stretch" Width="Auto">

     <data:DataGrid x:Name="dgEmpDept"/>

     </ScrollViewer>

     </StackPanel>

    </UserControl>


    And finally, modify the code-behind so that it looks like the following:


    Partial Public Class Page5

    Inherits UserControl


    Public Sub New()

    InitializeComponent()

    End Sub


    Private Sub btnShow_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnShow.Click

    Me.lblMsg.Text = "Fetching..."

    Dim objService As New EmpService.EmpServiceClient

    AddHandler objService.GetEnameDnameCompleted, AddressOf EmployeeListFetched

    objService.GetEnameDnameAsync()

    End Sub


    Private Sub EmployeeListFetched(ByVal sender As Object, ByVal e As EmpService.GetEnameDnameCompletedEventArgs)

    Me.dgEmpDept.ItemsSource = e.Result

    Me.lblMsg.Text = "Fetched!"

    End Sub


    Private Sub btnShowSalAlso_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnShowSalAlso.Click

    Me.lblMsg.Text = "Fetching..."

    Dim objService As New EmpService.EmpServiceClient

    AddHandler objService.GetEnameDnameSalCompleted, AddressOf EmployeeListFetched

    objService.GetEnameDnameSalAsync()

    End Sub


    Private Sub EmployeeListFetched(ByVal sender As Object, ByVal e As EmpService.GetEnameDnameSalCompletedEventArgs)

    Me.dgEmpDept.ItemsSource = e.Result

    Me.lblMsg.Text = "Fetched!"

    End Sub


    End Class


    In my upcoming articles, we will see more and more examples of Silverlight 2.0 development together with LINQ to SQL and WCF. I hope you enjoyed the article and any suggestions, bugs, errors, enhancements etc. are highly appreciated at http://jagchat.spaces.live.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hai,This is my next article in the series of WCF tutorials. Enjoy and let me...
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek