C# 3.0入门系列(七)--之OR工具介绍(下)2010-06-13 博客园 Tom Song打开DataClasses1. Designer.cs 文件,你就可以看到OR Designer给你产生的映射代码了。using System.Data.Linq; using System.Data.Linq.Mapping; using System.Data; using System.Collections.Generic; using System.Reflection; using System.Linq; using System.ComponentModel; using System;
[System.Data.Linq.Mapping.DatabaseAttribute(Name="northwind_may06ctp")] public partial class DataClasses1DataContext : System.Data.Linq.DataContext …{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
public Order() …{ OnCreated(); this._Order_Details = new EntitySet<Order_Detail>(new Action<Order_Detail>(this.attach_Order_Details), new Action<Order_Detail>(this.detach_Order_Details)); }
[Column(Storage="_OrderID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] public int OrderID …{ get …{ return this._OrderID; } set …{ if ((this._OrderID != value)) …{ this.OnOrderIDChanging(value); this.SendPropertyChanging(); this._OrderID = value; this.SendPropertyChanged("OrderID"); this.OnOrderIDChanged(); } } }
[Column(Storage="_CustomerID", DbType="NChar(5)")] public string CustomerID …{ get …{ return this._CustomerID; } set …{ if ((this._CustomerID != value)) …{ this.OnCustomerIDChanging(value); this.SendPropertyChanging(); this._CustomerID = value; this.SendPropertyChanged("CustomerID"); this.OnCustomerIDChanged(); } } }
[Column(Storage="_EmployeeID", DbType="Int")] public System.Nullable<int> EmployeeID …{ get …{ return this._EmployeeID; } set …{ if ((this._EmployeeID != value)) …{ this.OnEmployeeIDChanging(value); this.SendPropertyChanging(); this._EmployeeID = value; this.SendPropertyChanged("EmployeeID"); this.OnEmployeeIDChanged(); } } }
[Column(Storage="_OrderDate", DbType="DateTime")] public System.Nullable<System.DateTime> OrderDate …{ get …{ return this._OrderDate; } set …{ if ((this._OrderDate != value)) …{ this.OnOrderDateChanging(value); this.SendPropertyChanging(); this._OrderDate = value; this.SendPropertyChanged("OrderDate"); this.OnOrderDateChanged(); } } }
[Column(Storage="_RequiredDate", DbType="DateTime")] public System.Nullable<System.DateTime> RequiredDate …{ get …{ return this._RequiredDate; } set …{ if ((this._RequiredDate != value)) …{ this.OnRequiredDateChanging(value); this.SendPropertyChanging(); this._RequiredDate = value; this.SendPropertyChanged("RequiredDate"); this.OnRequiredDateChanged(); } } }
[Column(Storage="_ShippedDate", DbType="DateTime")] public System.Nullable<System.DateTime> ShippedDate …{ get …{ return this._ShippedDate; } set …{ if ((this._ShippedDate != value)) …{ this.OnShippedDateChanging(value); this.SendPropertyChanging(); this._ShippedDate = value; this.SendPropertyChanged("ShippedDate"); this.OnShippedDateChanged(); } } }
[Column(Storage="_ShipVia", DbType="Int")] public System.Nullable<int> ShipVia …{ get …{ return this._ShipVia; } set …{ if ((this._ShipVia != value)) …{ this.OnShipViaChanging(value); this.SendPropertyChanging(); this._ShipVia = value; this.SendPropertyChanged("ShipVia"); this.OnShipViaChanged(); } } }
[Column(Storage="_Freight", DbType="Money")] public System.Nullable<decimal> Freight …{ get …{ return this._Freight; } set …{ if ((this._Freight != value)) …{ this.OnFreightChanging(value); this.SendPropertyChanging(); this._Freight = value; this.SendPropertyChanged("Freight"); this.OnFreightChanged(); } } }
[Column(Storage="_ShipName", DbType="NVarChar(40)")] public string ShipName …{ get …{ return this._ShipName; } set …{ if ((this._ShipName != value)) …{ this.OnShipNameChanging(value); this.SendPropertyChanging(); this._ShipName = value; this.SendPropertyChanged("ShipName"); this.OnShipNameChanged(); } } }
[Column(Storage="_ShipAddress", DbType="NVarChar(60)")] public string ShipAddress …{ get …{ return this._ShipAddress; } set …{ if ((this._ShipAddress != value)) …{ this.OnShipAddressChanging(value); this.SendPropertyChanging(); this._ShipAddress = value; this.SendPropertyChanged("ShipAddress"); this.OnShipAddressChanged(); } } }
[Column(Storage="_ShipCity", DbType="NVarChar(15)")] public string ShipCity …{ get …{ return this._ShipCity; } set …{ if ((this._ShipCity != value)) …{ this.OnShipCityChanging(value); this.SendPropertyChanging(); this._ShipCity = value; this.SendPropertyChanged("ShipCity"); this.OnShipCityChanged(); } } }
[Column(Storage="_ShipRegion", DbType="NVarChar(15)")] public string ShipRegion …{ get …{ return this._ShipRegion; } set …{ if ((this._ShipRegion != value)) …{ this.OnShipRegionChanging(value); this.SendPropertyChanging(); this._ShipRegion = value; this.SendPropertyChanged("ShipRegion"); this.OnShipRegionChanged(); } } }
[Column(Storage="_ShipPostalCode", DbType="NVarChar(10)")] public string ShipPostalCode …{ get …{ return this._ShipPostalCode; } set …{ if ((this._ShipPostalCode != value)) …{ this.OnShipPostalCodeChanging(value); this.SendPropertyChanging(); this._ShipPostalCode = value; this.SendPropertyChanged("ShipPostalCode"); this.OnShipPostalCodeChanged(); } } }
[Column(Storage="_ShipCountry", DbType="NVarChar(15)")] public string ShipCountry …{ get …{ return this._ShipCountry; } set …{ if ((this._ShipCountry != value)) …{ this.OnShipCountryChanging(value); this.SendPropertyChanging(); this._ShipCountry = value; this.SendPropertyChanged("ShipCountry"); this.OnShipCountryChanged(); } } }
[Association(Name="Order_Order_Detail", Storage="_Order_Details", OtherKey="OrderID")] public EntitySet<Order_Detail> Order_Details …{ get …{ return this._Order_Details; } set …{ this._Order_Details.Assign(value); } }
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
public Order_Detail() …{ OnCreated(); this._Order = default(EntityRef<Order>); }
[Column(Storage="_OrderID", DbType="Int NOT NULL", IsPrimaryKey=true)] public int OrderID …{ get …{ return this._OrderID; } set …{ if ((this._OrderID != value)) …{ if (this._Order.HasLoadedOrAssignedValue) …{ throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); } this.OnOrderIDChanging(value); this.SendPropertyChanging(); this._OrderID = value; this.SendPropertyChanged("OrderID"); this.OnOrderIDChanged(); } } }
[Column(Storage="_ProductID", DbType="Int NOT NULL", IsPrimaryKey=true)] public int ProductID …{ get …{ return this._ProductID; } set …{ if ((this._ProductID != value)) …{ this.OnProductIDChanging(value); this.SendPropertyChanging(); this._ProductID = value; this.SendPropertyChanged("ProductID"); this.OnProductIDChanged(); } } }
[Column(Storage="_UnitPrice", DbType="Money NOT NULL")] public decimal UnitPrice …{ get …{ return this._UnitPrice; } set …{ if ((this._UnitPrice != value)) …{ this.OnUnitPriceChanging(value); this.SendPropertyChanging(); this._UnitPrice = value; this.SendPropertyChanged("UnitPrice"); this.OnUnitPriceChanged(); } } }
[Column(Storage="_Quantity", DbType="SmallInt NOT NULL")] public short Quantity …{ get …{ return this._Quantity; } set …{ if ((this._Quantity != value)) …{ this.OnQuantityChanging(value); this.SendPropertyChanging(); this._Quantity = value; this.SendPropertyChanged("Quantity"); this.OnQuantityChanged(); } } }
[Column(Storage="_Discount", DbType="Real NOT NULL")] public float Discount …{ get …{ return this._Discount; } set …{ if ((this._Discount != value)) …{ this.OnDiscountChanging(value); this.SendPropertyChanging(); this._Discount = value; this.SendPropertyChanged("Discount"); this.OnDiscountChanged(); } } }
[Association(Name="Order_Order_Detail", Storage="_Order", ThisKey="OrderID", IsForeignKey=true)] public Order Order …{ get …{ return this._Order.Entity; } set …{ Order previousValue = this._Order.Entity; if (((previousValue != value) || (this._Order.HasLoadedOrAssignedValue == false))) …{ this.SendPropertyChanging(); if ((previousValue != null)) …{ this._Order.Entity = null; previousValue.Order_Details.Remove(this); } this._Order.Entity = value; if ((value != null)) …{ value.Order_Details.Add(this); this._OrderID = value.OrderID; } else …{ this._OrderID = default(int); } this.SendPropertyChanged("Order"); } } }
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;