Silverlight中“LINQtoSQL类”的疑问,该如何解决
Silverlight中“LINQtoSQL类”的疑问
#pragma warning disable 1591
namespace _11.LINQtoSQL.Web
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;
问题一:“VS2010”中的“LINQtoSQL类”文件,有什么优势吗?是不是可以不用写“增、删、改、查”这些SQL语句,不用SQL语句???增、删、改、查又是怎样实现的???
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="NORTHWND")]
问题二:这句话的作用是什么呢?
public partial class DataClasses1DataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
问题三:这句话的作用是什么?“AttributeMappingSource”指什么嘞,数据库映射吗?
#region 可扩展性方法定义
partial void OnCreated();
partial void InsertProduct(Product instance);
partial void UpdateProduct(Product instance);
partial void DeleteProduct(Product instance);
问题三:“OnCreated()”是自动创建的,“InsertProduct”、“UpdateProduct”、“DeleteProduct”,是后来手动加上的把,就像“.cs”类中的一样?只有声明也没有具体的实现方法啊?
#endregion
public DataClasses1DataContext() :
base(global::System.Configuration.ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString, mappingSource)
{
OnCreated();
}
public DataClasses1DataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public DataClasses1DataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public DataClasses1DataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public DataClasses1DataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
问题四:这几个“DataClasses1DataContext”是建立数据库连接的不同的方法,对吧? public System.Data.Linq.Table<Product> Products
{
get
{
return this.GetTable<Product>();
}
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Products")]
public partial class Product : INotifyPropertyChanging, INotifyPropertyChanged
问题五:这个类要被Sivlight使用所以,继承了“INotifyPropertyChanging, INotifyPropertyChanged”接口对吧???
问题六:“类”使用了“global::System.Data.Linq.Mapping.TableAttribute”,“属性”使用了“global::System.Data.Linq.Mapping.ColumnAttribute”,是不是将“Linq”
中的“Table”,转化为“类”中的属性了?
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _ProductID;
private string _ProductName;
private System.Nullable<int> _SupplierID;
private System.Nullable<int> _CategoryID;
private string _QuantityPerUnit;
private System.Nullable<decimal> _UnitPrice;
private System.Nullable<short> _UnitsInStock;
private System.Nullable<short> _UnitsOnOrder;
private System.Nullable<short> _ReorderLevel;
private bool _Discontinued;
#region 可扩展性方法定义
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnProductIDChanging(int value);
partial void OnProductIDChanged();
partial void OnProductNameChanging(string value);
#pragma warning disable 1591
namespace _11.LINQtoSQL.Web
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;
问题一:“VS2010”中的“LINQtoSQL类”文件,有什么优势吗?是不是可以不用写“增、删、改、查”这些SQL语句,不用SQL语句???增、删、改、查又是怎样实现的???
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="NORTHWND")]
问题二:这句话的作用是什么呢?
public partial class DataClasses1DataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
问题三:这句话的作用是什么?“AttributeMappingSource”指什么嘞,数据库映射吗?
#region 可扩展性方法定义
partial void OnCreated();
partial void InsertProduct(Product instance);
partial void UpdateProduct(Product instance);
partial void DeleteProduct(Product instance);
问题三:“OnCreated()”是自动创建的,“InsertProduct”、“UpdateProduct”、“DeleteProduct”,是后来手动加上的把,就像“.cs”类中的一样?只有声明也没有具体的实现方法啊?
#endregion
public DataClasses1DataContext() :
base(global::System.Configuration.ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString, mappingSource)
{
OnCreated();
}
public DataClasses1DataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public DataClasses1DataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public DataClasses1DataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public DataClasses1DataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
问题四:这几个“DataClasses1DataContext”是建立数据库连接的不同的方法,对吧? public System.Data.Linq.Table<Product> Products
{
get
{
return this.GetTable<Product>();
}
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Products")]
public partial class Product : INotifyPropertyChanging, INotifyPropertyChanged
问题五:这个类要被Sivlight使用所以,继承了“INotifyPropertyChanging, INotifyPropertyChanged”接口对吧???
问题六:“类”使用了“global::System.Data.Linq.Mapping.TableAttribute”,“属性”使用了“global::System.Data.Linq.Mapping.ColumnAttribute”,是不是将“Linq”
中的“Table”,转化为“类”中的属性了?
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _ProductID;
private string _ProductName;
private System.Nullable<int> _SupplierID;
private System.Nullable<int> _CategoryID;
private string _QuantityPerUnit;
private System.Nullable<decimal> _UnitPrice;
private System.Nullable<short> _UnitsInStock;
private System.Nullable<short> _UnitsOnOrder;
private System.Nullable<short> _ReorderLevel;
private bool _Discontinued;
#region 可扩展性方法定义
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnProductIDChanging(int value);
partial void OnProductIDChanged();
partial void OnProductNameChanging(string value);