Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - 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 - Creating WCF DataContract classes visually using LINQ to SQL Designer: Accessing in Silverlight


    (Page 3 of 5 )

    In the previous section, we have seen how we can create "DataContract" classes easily using the "LINQ to SQL Designer." Now, the goal is to access the same in a Silverlight application.

    Modify IEmpService.vb as follows:


    <ServiceContract()> _

    Public Interface IEmpService


    <OperationContract()> _

    Function GetEnameDname() As List(Of EnameDname)


    End Interface


    Modify "EmpService.vb" as follows:


    Imports System.Data.Linq


    Public Class EmpService

    Implements IEmpService


    Public Sub New()

    End Sub


    Public Function GetEnameDname() As System.Collections.Generic.List(Of EnameDname) Implements IEmpService.GetEnameDname

    Using ctxt As New DemoEmpDataContext

    ctxt.ObjectTrackingEnabled = False

    Return (From p In ctxt.Emps _

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

    End Using

    End Function


    End Class


    Modify the Silverlight UI markup as follows:


    <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"/>

     <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, make the code-behind as follows:


    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


    End Class


    More Windows Scripting Articles
    More By Jagadish Chaterjee


       · 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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek