Click here to Skip to main content
15,886,755 members
Articles / Programming Languages / C# 4.0

A Random Walk Through of the LightSwitch Data Model

Rate me:
Please Sign up or sign in to vote.
4.93/5 (20 votes)
10 Sep 2011Ms-PL4 min read 41.5K   563   22  
We will create a Silverlight Custom Control called “LightSwitch Explorer” that will display information about the collections of the screen that it is displayed on, raise methods, and switch screens.
  • LightSwitchExplorer.zip
    • LightSwitchExplorer.sln
    • LightSwitchExplorer
      • _Pvt_Extensions
        • Microsoft.LightSwitch.Extensions
          • Client
            • DebugOnlyRef
              • Microsoft.LightSwitch.Extensions.Design.Client.dll
          • ClientGen
            • Reference
              • ar
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • bg
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • ca
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • cs
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • da
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • de
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • el
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • es
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • et
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • eu
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • fi
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • fr
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • he
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • hr
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • hu
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • id
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • it
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • ja
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • ko
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • lt
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • lv
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • Microsoft.LightSwitch.Extensions.Client.dll
              • ms
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • nl
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • no
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • pl
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • pt
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • pt-BR
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • ro
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • ru
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • sk
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • sl
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • sr-Cyrl-CS
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • sr-Latn-CS
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • sv
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • th
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • tr
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • uk
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • vi
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • zh-Hans
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
              • zh-Hant
                • Microsoft.LightSwitch.Extensions.Client.Resources.dll
          • IDE
            • Reference
              • de
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
              • es
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
              • fr
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
              • it
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
              • ja
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
              • ko
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
              • Microsoft.LightSwitch.Extensions.Design.dll
              • ru
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
              • zh-Hans
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
              • zh-Hant
                • Microsoft.LightSwitch.Extensions.Design.Resources.dll
          • LsPkgLastWriteTime.txt
          • ServerGen
            • Reference
              • ar
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • bg
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • ca
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • cs
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • da
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • de
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • el
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • es
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • et
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • eu
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • fi
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • fr
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • he
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • hr
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • hu
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • id
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • it
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • ja
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • ko
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • lt
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • lv
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • Microsoft.LightSwitch.Extensions.Server.dll
              • ms
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • nl
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • no
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • pl
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • pt
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • pt-BR
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • ro
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • ru
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • sk
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • sl
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • sr-Cyrl-CS
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • sr-Latn-CS
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • sv
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • th
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • tr
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • uk
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • vi
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • zh-Hans
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
              • zh-Hant
                • Microsoft.LightSwitch.Extensions.Server.Resources.dll
      • app.config
      • Bin
        • Data
          • ApplicationDatabase.mdf
          • ApplicationDatabase_log.ldf
          • Temp
        • Debug
          • bin
            • ar
            • bg
            • ca
            • cs
            • da
            • de
            • el
            • es
            • et
            • eu
            • fi
            • fr
            • he
            • hr
            • hu
            • id
            • it
            • ja
            • ko
            • lt
            • lv
            • Microsoft.LightSwitch.Design.Server.Internal.dll
            • ms
            • nl
            • no
            • pl
            • pt
            • pt-BR
            • ro
            • ru
            • sk
            • sl
            • sr-Cyrl-CS
            • sr-Latn-CS
            • sv
            • th
            • tr
            • uk
            • vi
            • zh-Hans
            • zh-Hant
          • Data
          • VslsHost.exe
          • Web
            • Manifests
              • Microsoft.LightSwitch.Design.Server.Manifest.dll
      • Client
      • ClientGenerated
      • Common
      • Data
        • ApplicationDefinition.lsml
      • default.htm
      • LightSwitchExplorer.lsproj
      • LightSwitchExplorer.lsproj.user
      • Server
      • ServerGenerated
      • ServiceConfiguration.cscfg
      • ServiceDefinition.csdef
      • Silverlight.js
    • SilverlightControlLibrary
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace LightSwitchApplication.Implementation
{
    
    #region Product
    [global::System.Runtime.Serialization.DataContract(Namespace = "http://schemas.datacontract.org/2004/07/ApplicationData.Implementation")]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.LightSwitch.BuildTasks.CodeGen", "10.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public sealed class Product :
        global::System.ServiceModel.DomainServices.Client.Entity,
        global::LightSwitchApplication.Product.DetailsClass.IImplementation
    {
        public override object GetIdentity()
        {
            if (this.__host != null && this.__host.IsNewlyAdded)
            {
                return null;
            }
    
            return this._Id;
        }
        [global::System.ComponentModel.DataAnnotations.Key()]
        [global::System.ComponentModel.DataAnnotations.Editable(false, AllowInitialValue = true)]
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public int Id
        {
            get
            {
                return this._Id;
            }
            set
            {
                if (this._Id != value)
                {
                    this.ValidateProperty("Id", value);
                    this._Id = value;
                    this.RaisePropertyChanged("Id");
                }
            }
        }
        private int _Id;
        
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public string ProductName
        {
            get
            {
                return this._ProductName;
            }
            set
            {
                if (this._ProductName != value)
                {
                    this.RaiseDataMemberChanging("ProductName");
                    this.ValidateProperty("ProductName", value);
                    this._ProductName = value;
                    this.RaiseDataMemberChanged("ProductName");
                }
            }
        }
        private string _ProductName;
        
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public decimal ProductPrice
        {
            get
            {
                return this._ProductPrice;
            }
            set
            {
                if (this._ProductPrice != value)
                {
                    this.RaiseDataMemberChanging("ProductPrice");
                    this.ValidateProperty("ProductPrice", value);
                    this._ProductPrice = value;
                    this.RaiseDataMemberChanged("ProductPrice");
                }
            }
        }
        private decimal _ProductPrice;
        
        [global::System.ComponentModel.DataAnnotations.Association("OrderDetail_Product", "Id", "OrderDetail_Product")]
        [global::System.Xml.Serialization.XmlIgnore()]
        public global::System.ServiceModel.DomainServices.Client.EntityCollection<OrderDetail> OrderDetails
        {
            get
            {
                if (this._OrderDetails == null)
                {
                    this._OrderDetails = new global::System.ServiceModel.DomainServices.Client.EntityCollection<global::LightSwitchApplication.Implementation.OrderDetail>(this, "OrderDetails", this.FilterOrderDetails, this.AttachOrderDetails, this.DetachOrderDetails);
                }
                return this._OrderDetails;
            }
        }
        private global::System.ServiceModel.DomainServices.Client.EntityCollection<global::LightSwitchApplication.Implementation.OrderDetail> _OrderDetails;
        private void AttachOrderDetails(global::LightSwitchApplication.Implementation.OrderDetail entity)
        {
            entity.Product = this;
        }
        private void DetachOrderDetails(global::LightSwitchApplication.Implementation.OrderDetail entity)
        {
            entity.Product = null;
        }
        private bool FilterOrderDetails(global::LightSwitchApplication.Implementation.OrderDetail entity)
        {
            return global::System.Object.Equals(entity.OrderDetail_Product, this.Id);
        }
        global::System.Collections.IEnumerable global::LightSwitchApplication.Product.DetailsClass.IImplementation.OrderDetails
        {
            get
            {
                return this.OrderDetails;
            }
        }
        
        #region IEntityImplementation Members
        private global::Microsoft.LightSwitch.Internal.IEntityImplementationHost __host;
        
        global::Microsoft.LightSwitch.Internal.IEntityImplementationHost global::Microsoft.LightSwitch.Internal.IEntityImplementation.Host
        {
            get
            {
                return this.__host;
            }
        }
        
        void global::Microsoft.LightSwitch.Internal.IEntityImplementation.Initialize(global::Microsoft.LightSwitch.Internal.IEntityImplementationHost host)
        {
            this.__host = host;
        }
        
        protected override void OnPropertyChanged(global::System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);
            if (this.__host != null)
            {
                this.__host.RaisePropertyChanged(e.PropertyName);
            }
        }
        #endregion
    }
    #endregion
    
    #region Order
    [global::System.Runtime.Serialization.DataContract(Namespace = "http://schemas.datacontract.org/2004/07/ApplicationData.Implementation")]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.LightSwitch.BuildTasks.CodeGen", "10.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public sealed class Order :
        global::System.ServiceModel.DomainServices.Client.Entity,
        global::LightSwitchApplication.Order.DetailsClass.IImplementation
    {
        public override object GetIdentity()
        {
            if (this.__host != null && this.__host.IsNewlyAdded)
            {
                return null;
            }
    
            return this._Id;
        }
        [global::System.ComponentModel.DataAnnotations.Key()]
        [global::System.ComponentModel.DataAnnotations.Editable(false, AllowInitialValue = true)]
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public int Id
        {
            get
            {
                return this._Id;
            }
            set
            {
                if (this._Id != value)
                {
                    this.ValidateProperty("Id", value);
                    this._Id = value;
                    this.RaisePropertyChanged("Id");
                }
            }
        }
        private int _Id;
        
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public string CustomerName
        {
            get
            {
                return this._CustomerName;
            }
            set
            {
                if (this._CustomerName != value)
                {
                    this.RaiseDataMemberChanging("CustomerName");
                    this.ValidateProperty("CustomerName", value);
                    this._CustomerName = value;
                    this.RaiseDataMemberChanged("CustomerName");
                }
            }
        }
        private string _CustomerName;
        
        [global::System.ComponentModel.DataAnnotations.Association("OrderDetail_Order", "Id", "OrderDetail_Order")]
        [global::System.Xml.Serialization.XmlIgnore()]
        public global::System.ServiceModel.DomainServices.Client.EntityCollection<OrderDetail> OrderDetails
        {
            get
            {
                if (this._OrderDetails == null)
                {
                    this._OrderDetails = new global::System.ServiceModel.DomainServices.Client.EntityCollection<global::LightSwitchApplication.Implementation.OrderDetail>(this, "OrderDetails", this.FilterOrderDetails, this.AttachOrderDetails, this.DetachOrderDetails);
                }
                return this._OrderDetails;
            }
        }
        private global::System.ServiceModel.DomainServices.Client.EntityCollection<global::LightSwitchApplication.Implementation.OrderDetail> _OrderDetails;
        private void AttachOrderDetails(global::LightSwitchApplication.Implementation.OrderDetail entity)
        {
            entity.Order = this;
        }
        private void DetachOrderDetails(global::LightSwitchApplication.Implementation.OrderDetail entity)
        {
            entity.Order = null;
        }
        private bool FilterOrderDetails(global::LightSwitchApplication.Implementation.OrderDetail entity)
        {
            return global::System.Object.Equals(entity.OrderDetail_Order, this.Id);
        }
        global::System.Collections.IEnumerable global::LightSwitchApplication.Order.DetailsClass.IImplementation.OrderDetails
        {
            get
            {
                return this.OrderDetails;
            }
        }
        
        #region IEntityImplementation Members
        private global::Microsoft.LightSwitch.Internal.IEntityImplementationHost __host;
        
        global::Microsoft.LightSwitch.Internal.IEntityImplementationHost global::Microsoft.LightSwitch.Internal.IEntityImplementation.Host
        {
            get
            {
                return this.__host;
            }
        }
        
        void global::Microsoft.LightSwitch.Internal.IEntityImplementation.Initialize(global::Microsoft.LightSwitch.Internal.IEntityImplementationHost host)
        {
            this.__host = host;
        }
        
        protected override void OnPropertyChanged(global::System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);
            if (this.__host != null)
            {
                this.__host.RaisePropertyChanged(e.PropertyName);
            }
        }
        #endregion
    }
    #endregion
    
    #region OrderDetail
    [global::System.Runtime.Serialization.DataContract(Namespace = "http://schemas.datacontract.org/2004/07/ApplicationData.Implementation")]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.LightSwitch.BuildTasks.CodeGen", "10.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public sealed class OrderDetail :
        global::System.ServiceModel.DomainServices.Client.Entity,
        global::LightSwitchApplication.OrderDetail.DetailsClass.IImplementation
    {
        public override object GetIdentity()
        {
            if (this.__host != null && this.__host.IsNewlyAdded)
            {
                return null;
            }
    
            return this._Id;
        }
        [global::System.ComponentModel.DataAnnotations.Key()]
        [global::System.ComponentModel.DataAnnotations.Editable(false, AllowInitialValue = true)]
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public int Id
        {
            get
            {
                return this._Id;
            }
            set
            {
                if (this._Id != value)
                {
                    this.ValidateProperty("Id", value);
                    this._Id = value;
                    this.RaisePropertyChanged("Id");
                }
            }
        }
        private int _Id;
        
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public int Quantity
        {
            get
            {
                return this._Quantity;
            }
            set
            {
                if (this._Quantity != value)
                {
                    this.RaiseDataMemberChanging("Quantity");
                    this.ValidateProperty("Quantity", value);
                    this._Quantity = value;
                    this.RaiseDataMemberChanged("Quantity");
                }
            }
        }
        private int _Quantity;
        
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public int OrderDetail_Order
        {
            get
            {
                return this._OrderDetail_Order;
            }
            set
            {
                if (this._OrderDetail_Order != value)
                {
                    this.RaiseDataMemberChanging("OrderDetail_Order");
                    this.ValidateProperty("OrderDetail_Order", value);
                    this._OrderDetail_Order = value;
                    this.RaiseDataMemberChanged("OrderDetail_Order");
                }
            }
        }
        private int _OrderDetail_Order;
        
        [global::System.ComponentModel.DataAnnotations.Association("OrderDetail_Order", "OrderDetail_Order", "Id", IsForeignKey = true)]
        [global::System.Xml.Serialization.XmlIgnore()]
        public global::LightSwitchApplication.Implementation.Order Order
        {
            get
            {
                if (this._Order == null)
                {
                    this._Order = new global::System.ServiceModel.DomainServices.Client.EntityRef<global::LightSwitchApplication.Implementation.Order>(this, "Order", this.FilterOrder);
                }
                return this._Order.Entity;
            }
            set
            {
                Order previous = this.Order;
                if (previous != value)
                {
                    this.ValidateProperty("Order", value);
                    if (previous != null)
                    {
                        this._Order.Entity = null;
                        previous.OrderDetails.Remove(this);
                    }
                    if (value != null)
                    {
                        this.OrderDetail_Order = value.Id;
                    }
                    else
                    {
                        this.OrderDetail_Order = default(int);
                    }
                    this._Order.Entity = value;
                    if (value != null)
                    {
                        value.OrderDetails.Add(this);
                    }
                    this.RaisePropertyChanged("Order");
                }
            }
        }
        private global::System.ServiceModel.DomainServices.Client.EntityRef<global::LightSwitchApplication.Implementation.Order> _Order;
        private bool FilterOrder(global::LightSwitchApplication.Implementation.Order entity)
        {
            return global::System.Object.Equals(entity.Id, this.OrderDetail_Order);
        }
        global::Microsoft.LightSwitch.Internal.IEntityImplementation global::LightSwitchApplication.OrderDetail.DetailsClass.IImplementation.Order
        {
            get
            {
                return this.Order;
            }
            set
            {
                this.Order = (global::LightSwitchApplication.Implementation.Order)value;
            }
        }
        
        [global::System.Runtime.Serialization.DataMember()]
        [global::System.ComponentModel.DataAnnotations.RoundtripOriginal()]
        public int OrderDetail_Product
        {
            get
            {
                return this._OrderDetail_Product;
            }
            set
            {
                if (this._OrderDetail_Product != value)
                {
                    this.RaiseDataMemberChanging("OrderDetail_Product");
                    this.ValidateProperty("OrderDetail_Product", value);
                    this._OrderDetail_Product = value;
                    this.RaiseDataMemberChanged("OrderDetail_Product");
                }
            }
        }
        private int _OrderDetail_Product;
        
        [global::System.ComponentModel.DataAnnotations.Association("OrderDetail_Product", "OrderDetail_Product", "Id", IsForeignKey = true)]
        [global::System.Xml.Serialization.XmlIgnore()]
        public global::LightSwitchApplication.Implementation.Product Product
        {
            get
            {
                if (this._Product == null)
                {
                    this._Product = new global::System.ServiceModel.DomainServices.Client.EntityRef<global::LightSwitchApplication.Implementation.Product>(this, "Product", this.FilterProduct);
                }
                return this._Product.Entity;
            }
            set
            {
                Product previous = this.Product;
                if (previous != value)
                {
                    this.ValidateProperty("Product", value);
                    if (previous != null)
                    {
                        this._Product.Entity = null;
                        previous.OrderDetails.Remove(this);
                    }
                    if (value != null)
                    {
                        this.OrderDetail_Product = value.Id;
                    }
                    else
                    {
                        this.OrderDetail_Product = default(int);
                    }
                    this._Product.Entity = value;
                    if (value != null)
                    {
                        value.OrderDetails.Add(this);
                    }
                    this.RaisePropertyChanged("Product");
                }
            }
        }
        private global::System.ServiceModel.DomainServices.Client.EntityRef<global::LightSwitchApplication.Implementation.Product> _Product;
        private bool FilterProduct(global::LightSwitchApplication.Implementation.Product entity)
        {
            return global::System.Object.Equals(entity.Id, this.OrderDetail_Product);
        }
        global::Microsoft.LightSwitch.Internal.IEntityImplementation global::LightSwitchApplication.OrderDetail.DetailsClass.IImplementation.Product
        {
            get
            {
                return this.Product;
            }
            set
            {
                this.Product = (global::LightSwitchApplication.Implementation.Product)value;
            }
        }
        
        #region IEntityImplementation Members
        private global::Microsoft.LightSwitch.Internal.IEntityImplementationHost __host;
        
        global::Microsoft.LightSwitch.Internal.IEntityImplementationHost global::Microsoft.LightSwitch.Internal.IEntityImplementation.Host
        {
            get
            {
                return this.__host;
            }
        }
        
        void global::Microsoft.LightSwitch.Internal.IEntityImplementation.Initialize(global::Microsoft.LightSwitch.Internal.IEntityImplementationHost host)
        {
            this.__host = host;
        }
        
        protected override void OnPropertyChanged(global::System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);
            if (this.__host != null)
            {
                this.__host.RaisePropertyChanged(e.PropertyName);
            }
        }
        #endregion
    }
    #endregion
    
    #region ApplicationData
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.LightSwitch.BuildTasks.CodeGen", "10.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public class ApplicationData
        : global::Microsoft.LightSwitch.ClientGenerated.Implementation.DomainContext
    {
        public ApplicationData(global::Microsoft.LightSwitch.IDataService dataService)
            : base(dataService, global::Microsoft.LightSwitch.ClientGenerated.Implementation.DomainContext.CreateWcfDomainClient<IApplicationDataContract>(new global::System.Uri("LightSwitchApplication-Implementation-ApplicationDataDomainService.svc", global::System.UriKind.Relative)))
        {
        }
    
        public global::System.ServiceModel.DomainServices.Client.EntitySet<global::LightSwitchApplication.Implementation.Product> ProductEntityList
        {
            get
            {
                return base.EntityContainer.GetEntitySet<global::LightSwitchApplication.Implementation.Product>();
            }
        }
        public global::System.ServiceModel.DomainServices.Client.EntitySet<global::LightSwitchApplication.Implementation.Order> OrderEntityList
        {
            get
            {
                return base.EntityContainer.GetEntitySet<global::LightSwitchApplication.Implementation.Order>();
            }
        }
        public global::System.ServiceModel.DomainServices.Client.EntitySet<global::LightSwitchApplication.Implementation.OrderDetail> OrderDetailEntityList
        {
            get
            {
                return base.EntityContainer.GetEntitySet<global::LightSwitchApplication.Implementation.OrderDetail>();
            }
        }
        protected override global::System.ServiceModel.DomainServices.Client.EntityContainer CreateEntityContainer()
        {
            return new ApplicationDataEntityContainer();
        }
    
        internal sealed class ApplicationDataEntityContainer : global::System.ServiceModel.DomainServices.Client.EntityContainer
        {
            public ApplicationDataEntityContainer()
            {
                this.CreateEntitySet<global::LightSwitchApplication.Implementation.Product>(global::System.ServiceModel.DomainServices.Client.EntitySetOperations.All);
                this.CreateEntitySet<global::LightSwitchApplication.Implementation.Order>(global::System.ServiceModel.DomainServices.Client.EntitySetOperations.All);
                this.CreateEntitySet<global::LightSwitchApplication.Implementation.OrderDetail>(global::System.ServiceModel.DomainServices.Client.EntitySetOperations.All);
            }
        }
    
        #region Service Contract Interface
    
        [global::System.ServiceModel.ServiceContract]
        public interface IApplicationDataContract
        {
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/Products_Single", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/Products_SingleResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/Products_SingleDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginProducts_Single(string frameworkOperators, global::System.Nullable<int> Id, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.Product> EndProducts_Single(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/Products_SingleOrDefault", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/Products_SingleOrDefaultResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/Products_SingleOrDefaultDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginProducts_SingleOrDefault(string frameworkOperators, global::System.Nullable<int> Id, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.Product> EndProducts_SingleOrDefault(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/Products_All", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/Products_AllResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/Products_AllDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginProducts_All(string frameworkOperators, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.Product> EndProducts_All(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/Orders_Single", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/Orders_SingleResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/Orders_SingleDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginOrders_Single(string frameworkOperators, global::System.Nullable<int> Id, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.Order> EndOrders_Single(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/Orders_SingleOrDefault", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/Orders_SingleOrDefaultResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/Orders_SingleOrDefaultDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginOrders_SingleOrDefault(string frameworkOperators, global::System.Nullable<int> Id, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.Order> EndOrders_SingleOrDefault(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/Orders_All", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/Orders_AllResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/Orders_AllDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginOrders_All(string frameworkOperators, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.Order> EndOrders_All(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_Single", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_SingleResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_SingleDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginOrderDetails_Single(string frameworkOperators, global::System.Nullable<int> Id, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.OrderDetail> EndOrderDetails_Single(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_SingleOrDefault", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_SingleOrDefaultResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_SingleOrDefaultDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginOrderDetails_SingleOrDefault(string frameworkOperators, global::System.Nullable<int> Id, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.OrderDetail> EndOrderDetails_SingleOrDefault(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_All", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_AllResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/OrderDetails_AllDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginOrderDetails_All(string frameworkOperators, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.ServiceModel.DomainServices.Client.QueryResult<global::LightSwitchApplication.Implementation.OrderDetail> EndOrderDetails_All(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/SubmitChanges", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/SubmitChangesResponse"),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/SubmitChangesDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult BeginSubmitChanges(global::System.Collections.Generic.IEnumerable<global::System.ServiceModel.DomainServices.Client.ChangeSetEntry> changeSet, global::System.AsyncCallback callback, global::System.Object asyncState);
            global::System.Collections.Generic.IEnumerable<global::System.ServiceModel.DomainServices.Client.ChangeSetEntry> EndSubmitChanges(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/__GetEntitySetCanInformation", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/__GetEntitySetCanInformationResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/__GetEntitySetCanInformationDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult Begin__GetEntitySetCanInformation(string entitySetName, global::System.AsyncCallback callback, global::System.Object asyncState);
            int End__GetEntitySetCanInformation(global::System.IAsyncResult result);
            
            [global::System.ServiceModel.OperationContract(AsyncPattern = true, Action = "http://tempuri.org/ApplicationDataDomainService/__CanExecuteOperation", ReplyAction = "http://tempuri.org/ApplicationDataDomainService/__CanExecuteOperationResponse"),
             global::System.ServiceModel.Web.WebGet(),
             global::System.ServiceModel.FaultContract(typeof(global::System.ServiceModel.DomainServices.Client.DomainServiceFault), Action = "http://tempuri.org/ApplicationDataDomainService/__CanExecuteOperationDomainServiceFault", Name = "DomainServiceFault", Namespace = "DomainServices")]
            global::System.IAsyncResult Begin__CanExecuteOperation(string operationName, global::System.AsyncCallback callback, global::System.Object asyncState);
            bool End__CanExecuteOperation(global::System.IAsyncResult result);
            
        }
    
        #endregion
    
        protected override global::Microsoft.LightSwitch.Internal.IEntityImplementation CreateEntityImplementation<T>()
        {
            if (typeof(T) == typeof(global::LightSwitchApplication.Product))
            {
                return new global::LightSwitchApplication.Implementation.Product();
            }
            if (typeof(T) == typeof(global::LightSwitchApplication.Order))
            {
                return new global::LightSwitchApplication.Implementation.Order();
            }
            if (typeof(T) == typeof(global::LightSwitchApplication.OrderDetail))
            {
                return new global::LightSwitchApplication.Implementation.OrderDetail();
            }
            return null;
        }
    }
    #endregion
    
    #region DataServiceImplementationFactory
    [global::System.ComponentModel.Composition.PartCreationPolicy(global::System.ComponentModel.Composition.CreationPolicy.Shared)]
    [global::System.ComponentModel.Composition.Export(typeof(global::Microsoft.LightSwitch.Internal.IDataServiceFactory))]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.LightSwitch.BuildTasks.CodeGen", "10.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public class DataServiceFactory :
        global::Microsoft.LightSwitch.ClientGenerated.Implementation.DataServiceFactory
    {
    
        protected override global::Microsoft.LightSwitch.IDataService CreateDataService(global::System.Type dataServiceType)
        {
            if (dataServiceType == typeof(global::LightSwitchApplication.ApplicationData))
            {
                return new global::LightSwitchApplication.ApplicationData();
            }
            return base.CreateDataService(dataServiceType);
        }
    
        protected override global::Microsoft.LightSwitch.Internal.IDataServiceImplementation CreateDataServiceImplementation<TDataService>(TDataService dataService)
        {
            if (typeof(TDataService) == typeof(global::LightSwitchApplication.ApplicationData))
            {
                return new global::LightSwitchApplication.Implementation.ApplicationData(dataService);
            }
            return base.CreateDataServiceImplementation(dataService);
        }
    }
    #endregion
    
    [global::System.ComponentModel.Composition.PartCreationPolicy(global::System.ComponentModel.Composition.CreationPolicy.Shared)]
    [global::System.ComponentModel.Composition.Export(typeof(global::Microsoft.LightSwitch.Internal.ITypeMappingProvider))]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.LightSwitch.BuildTasks.CodeGen", "10.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public class __TypeMapping
        : global::Microsoft.LightSwitch.Internal.ITypeMappingProvider
    {
        global::System.Type global::Microsoft.LightSwitch.Internal.ITypeMappingProvider.GetImplementationType(global::System.Type definitionType)
        {
            if (typeof(global::LightSwitchApplication.Product) == definitionType)
            {
                return typeof(global::LightSwitchApplication.Implementation.Product);
            }
            if (typeof(global::LightSwitchApplication.Order) == definitionType)
            {
                return typeof(global::LightSwitchApplication.Implementation.Order);
            }
            if (typeof(global::LightSwitchApplication.OrderDetail) == definitionType)
            {
                return typeof(global::LightSwitchApplication.Implementation.OrderDetail);
            }
            return null;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior) http://ADefWebserver.com
United States United States
Michael Washington is a Microsoft MVP. He is a ASP.NET and
C# programmer.
He is the founder of
AiHelpWebsite.com,
LightSwitchHelpWebsite.com, and
HoloLensHelpWebsite.com.

He has a son, Zachary and resides in Los Angeles with his wife Valerie.

He is the Author of:

Comments and Discussions