Click here to Skip to main content
15,884,177 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.4K   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 from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.EntityClient;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

[assembly: EdmSchemaAttribute()]
#region EDM Relationship Metadata

[assembly: EdmRelationshipAttribute("ApplicationData", "OrderDetail_Order", "Order", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(ApplicationData.Implementation.Order), "OrderDetail", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(ApplicationData.Implementation.OrderDetail), true)]
[assembly: EdmRelationshipAttribute("ApplicationData", "OrderDetail_Product", "Product", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(ApplicationData.Implementation.Product), "OrderDetail", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(ApplicationData.Implementation.OrderDetail), true)]

#endregion

namespace ApplicationData.Implementation
{
    #region Contexts
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    public partial class ApplicationDataObjectContext : ObjectContext
    {
        #region Constructors
    
        /// <summary>
        /// Initializes a new ApplicationDataObjectContext object using the connection string found in the 'ApplicationDataObjectContext' section of the application configuration file.
        /// </summary>
        public ApplicationDataObjectContext() : base("name=ApplicationDataObjectContext", "ApplicationDataObjectContext")
        {
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new ApplicationDataObjectContext object.
        /// </summary>
        public ApplicationDataObjectContext(string connectionString) : base(connectionString, "ApplicationDataObjectContext")
        {
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new ApplicationDataObjectContext object.
        /// </summary>
        public ApplicationDataObjectContext(EntityConnection connection) : base(connection, "ApplicationDataObjectContext")
        {
            OnContextCreated();
        }
    
        #endregion
    
        #region Partial Methods
    
        partial void OnContextCreated();
    
        #endregion
    
        #region ObjectSet Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Product> Products
        {
            get
            {
                if ((_Products == null))
                {
                    _Products = base.CreateObjectSet<Product>("Products");
                }
                return _Products;
            }
        }
        private ObjectSet<Product> _Products;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Order> Orders
        {
            get
            {
                if ((_Orders == null))
                {
                    _Orders = base.CreateObjectSet<Order>("Orders");
                }
                return _Orders;
            }
        }
        private ObjectSet<Order> _Orders;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<OrderDetail> OrderDetails
        {
            get
            {
                if ((_OrderDetails == null))
                {
                    _OrderDetails = base.CreateObjectSet<OrderDetail>("OrderDetails");
                }
                return _OrderDetails;
            }
        }
        private ObjectSet<OrderDetail> _OrderDetails;

        #endregion
        #region AddTo Methods
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToProducts(Product product)
        {
            base.AddObject("Products", product);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Orders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToOrders(Order order)
        {
            base.AddObject("Orders", order);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the OrderDetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToOrderDetails(OrderDetail orderDetail)
        {
            base.AddObject("OrderDetails", orderDetail);
        }

        #endregion
    }
    

    #endregion
    
    #region Entities
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ApplicationData", Name="Order")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Order : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Order object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="customerName">Initial value of the CustomerName property.</param>
        public static Order CreateOrder(global::System.Int32 id, global::System.String customerName)
        {
            Order order = new Order();
            order.Id = id;
            order.CustomerName = customerName;
            return order;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 Id
        {
            get
            {
                return _Id;
            }
            set
            {
                if (_Id != value)
                {
                    OnIdChanging(value);
                    ReportPropertyChanging("Id");
                    _Id = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("Id");
                    OnIdChanged();
                }
            }
        }
        private global::System.Int32 _Id;
        partial void OnIdChanging(global::System.Int32 value);
        partial void OnIdChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String CustomerName
        {
            get
            {
                return _CustomerName;
            }
            set
            {
                OnCustomerNameChanging(value);
                ReportPropertyChanging("CustomerName");
                _CustomerName = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("CustomerName");
                OnCustomerNameChanged();
            }
        }
        private global::System.String _CustomerName;
        partial void OnCustomerNameChanging(global::System.String value);
        partial void OnCustomerNameChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ApplicationData", "OrderDetail_Order", "OrderDetail")]
        public EntityCollection<OrderDetail> OrderDetails
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<OrderDetail>("ApplicationData.OrderDetail_Order", "OrderDetail");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<OrderDetail>("ApplicationData.OrderDetail_Order", "OrderDetail", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ApplicationData", Name="OrderDetail")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class OrderDetail : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new OrderDetail object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="quantity">Initial value of the Quantity property.</param>
        /// <param name="orderDetail_Order">Initial value of the OrderDetail_Order property.</param>
        /// <param name="orderDetail_Product">Initial value of the OrderDetail_Product property.</param>
        public static OrderDetail CreateOrderDetail(global::System.Int32 id, global::System.Int32 quantity, global::System.Int32 orderDetail_Order, global::System.Int32 orderDetail_Product)
        {
            OrderDetail orderDetail = new OrderDetail();
            orderDetail.Id = id;
            orderDetail.Quantity = quantity;
            orderDetail.OrderDetail_Order = orderDetail_Order;
            orderDetail.OrderDetail_Product = orderDetail_Product;
            return orderDetail;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 Id
        {
            get
            {
                return _Id;
            }
            set
            {
                if (_Id != value)
                {
                    OnIdChanging(value);
                    ReportPropertyChanging("Id");
                    _Id = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("Id");
                    OnIdChanged();
                }
            }
        }
        private global::System.Int32 _Id;
        partial void OnIdChanging(global::System.Int32 value);
        partial void OnIdChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 Quantity
        {
            get
            {
                return _Quantity;
            }
            set
            {
                OnQuantityChanging(value);
                ReportPropertyChanging("Quantity");
                _Quantity = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Quantity");
                OnQuantityChanged();
            }
        }
        private global::System.Int32 _Quantity;
        partial void OnQuantityChanging(global::System.Int32 value);
        partial void OnQuantityChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 OrderDetail_Order
        {
            get
            {
                return _OrderDetail_Order;
            }
            set
            {
                OnOrderDetail_OrderChanging(value);
                ReportPropertyChanging("OrderDetail_Order");
                _OrderDetail_Order = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("OrderDetail_Order");
                OnOrderDetail_OrderChanged();
            }
        }
        private global::System.Int32 _OrderDetail_Order;
        partial void OnOrderDetail_OrderChanging(global::System.Int32 value);
        partial void OnOrderDetail_OrderChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 OrderDetail_Product
        {
            get
            {
                return _OrderDetail_Product;
            }
            set
            {
                OnOrderDetail_ProductChanging(value);
                ReportPropertyChanging("OrderDetail_Product");
                _OrderDetail_Product = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("OrderDetail_Product");
                OnOrderDetail_ProductChanged();
            }
        }
        private global::System.Int32 _OrderDetail_Product;
        partial void OnOrderDetail_ProductChanging(global::System.Int32 value);
        partial void OnOrderDetail_ProductChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ApplicationData", "OrderDetail_Order", "Order")]
        public Order Order
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Order>("ApplicationData.OrderDetail_Order", "Order").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Order>("ApplicationData.OrderDetail_Order", "Order").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<Order> OrderReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Order>("ApplicationData.OrderDetail_Order", "Order");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Order>("ApplicationData.OrderDetail_Order", "Order", value);
                }
            }
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ApplicationData", "OrderDetail_Product", "Product")]
        public Product Product
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Product>("ApplicationData.OrderDetail_Product", "Product").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Product>("ApplicationData.OrderDetail_Product", "Product").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<Product> ProductReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Product>("ApplicationData.OrderDetail_Product", "Product");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Product>("ApplicationData.OrderDetail_Product", "Product", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ApplicationData", Name="Product")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Product : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Product object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="productName">Initial value of the ProductName property.</param>
        /// <param name="productPrice">Initial value of the ProductPrice property.</param>
        public static Product CreateProduct(global::System.Int32 id, global::System.String productName, global::System.Decimal productPrice)
        {
            Product product = new Product();
            product.Id = id;
            product.ProductName = productName;
            product.ProductPrice = productPrice;
            return product;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 Id
        {
            get
            {
                return _Id;
            }
            set
            {
                if (_Id != value)
                {
                    OnIdChanging(value);
                    ReportPropertyChanging("Id");
                    _Id = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("Id");
                    OnIdChanged();
                }
            }
        }
        private global::System.Int32 _Id;
        partial void OnIdChanging(global::System.Int32 value);
        partial void OnIdChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String ProductName
        {
            get
            {
                return _ProductName;
            }
            set
            {
                OnProductNameChanging(value);
                ReportPropertyChanging("ProductName");
                _ProductName = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("ProductName");
                OnProductNameChanged();
            }
        }
        private global::System.String _ProductName;
        partial void OnProductNameChanging(global::System.String value);
        partial void OnProductNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal ProductPrice
        {
            get
            {
                return _ProductPrice;
            }
            set
            {
                OnProductPriceChanging(value);
                ReportPropertyChanging("ProductPrice");
                _ProductPrice = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ProductPrice");
                OnProductPriceChanged();
            }
        }
        private global::System.Decimal _ProductPrice;
        partial void OnProductPriceChanging(global::System.Decimal value);
        partial void OnProductPriceChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("ApplicationData", "OrderDetail_Product", "OrderDetail")]
        public EntityCollection<OrderDetail> OrderDetails
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<OrderDetail>("ApplicationData.OrderDetail_Product", "OrderDetail");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<OrderDetail>("ApplicationData.OrderDetail_Product", "OrderDetail", value);
                }
            }
        }

        #endregion
    }

    #endregion
    
}

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