📄 ordersresultset.designer.cs
字号:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.312
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MobileDevelopersHandbook.DSAExample.OrdersResultSetResultSets {
using System;
using System.Data;
public partial class OrdersResultSet : System.Data.SqlServerCe.SqlCeResultSet {
private string resultSetConnectionString = null;
private System.Data.SqlServerCe.SqlCeConnection sqlCeConnection = null;
private System.Data.SqlServerCe.ResultSetOptions resultSetOptions;
public OrdersResultSet() {
// Create default options
//
resultSetOptions = System.Data.SqlServerCe.ResultSetOptions.Scrollable;
resultSetOptions = (resultSetOptions | System.Data.SqlServerCe.ResultSetOptions.Sensitive);
resultSetOptions = (resultSetOptions | System.Data.SqlServerCe.ResultSetOptions.Updatable);
// To enable design time support, the resultSetConnectionString property needs to switched between a Designtime and Runtime connection string.
// The design time connection string is used to make a valid connection to the database and retrieve schema information.
//
if (OrdersResultSetUtil.DesignerUtil.IsDesignTime()) {
// Designtime Connection String
resultSetConnectionString = "Data Source =\"C:\\Users\\Andy\\Documents\\Compact Framework Book V2.0\\Sample Code\\Cha" +
"pter 7\\CS\\DisconnectedServiceAgentExample\\DisconnectedServiceAgentExample\\AppDat" +
"abase.sdf\"";
}
else {
// Runtime Connection String
resultSetConnectionString = ("Data Source ="
+ (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\AppDatabase.sdf;"));
}
// Call Open() to initialize the ResultSet
//
this.Open();
}
public OrdersResultSet(string connectionString, System.Data.SqlServerCe.ResultSetOptions options) {
resultSetConnectionString = connectionString;
resultSetOptions = options;
this.Open();
}
public System.Data.SqlServerCe.SqlCeConnection Connection {
get {
return sqlCeConnection;
}
}
public int OrderId {
get {
return ((int)(base.GetInt32(base.GetOrdinal("OrderId"))));
}
set {
base.SetInt32(base.GetOrdinal("OrderId"), value);
}
}
public int ServerOrderId {
get {
try {
return ((int)(base.GetInt32(base.GetOrdinal("ServerOrderId"))));
}
catch (System.InvalidCastException e) {
throw new System.Data.StrongTypingException("StrongTyping_CananotAccessDBNull", e);
}
}
set {
base.SetInt32(base.GetOrdinal("ServerOrderId"), value);
}
}
public int ProductId {
get {
return ((int)(base.GetInt32(base.GetOrdinal("ProductId"))));
}
set {
base.SetInt32(base.GetOrdinal("ProductId"), value);
}
}
public int Quantity {
get {
return ((int)(base.GetInt32(base.GetOrdinal("Quantity"))));
}
set {
base.SetInt32(base.GetOrdinal("Quantity"), value);
}
}
public void Open() {
System.Data.SqlServerCe.SqlCeCommand sqlCeSelectCommand;
// Open a connection to the database
//
sqlCeConnection = new System.Data.SqlServerCe.SqlCeConnection(this.resultSetConnectionString);
sqlCeConnection.Open();
// Create the command
//
sqlCeSelectCommand = sqlCeConnection.CreateCommand();
sqlCeSelectCommand.CommandText = "Orders";
sqlCeSelectCommand.CommandType = System.Data.CommandType.TableDirect;
// Generate the ResultSet
//
sqlCeSelectCommand.ExecuteResultSet(this.resultSetOptions, this);
}
public void MoveToRow(int Row) {
base.ReadAbsolute(Row);
}
public void DeleteRecord() {
base.Delete();
}
public bool IsServerOrderIdNull() {
return base.IsDBNull(base.GetOrdinal("ServerOrderId"));
}
public void SetServerOrderIdNull() {
base.SetValue(base.GetOrdinal("ServerOrderId"), System.DBNull.Value);
}
public void AddOrdersRecord(int ServerOrderId, int ProductId, int Quantity) {
System.Data.SqlServerCe.SqlCeUpdatableRecord newRecord = base.CreateRecord();
newRecord["ServerOrderId"] = ServerOrderId;
newRecord["ProductId"] = ProductId;
newRecord["Quantity"] = Quantity;
base.Insert(newRecord);
}
public void Bind(System.Windows.Forms.BindingSource bindingSource) {
bindingSource.DataSource = this.ResultSetView;
}
}
}
namespace OrdersResultSetUtil {
using System;
using System.Data;
public partial class DesignerUtil {
public static bool IsDesignTime() {
// Determine if this instance is running against .NET Framework by using the MSCoreLib PublicKeyToken
System.Reflection.Assembly mscorlibAssembly = typeof(int).Assembly;
if ((mscorlibAssembly != null)) {
if (mscorlibAssembly.FullName.ToUpper().EndsWith("B77A5C561934E089")) {
return true;
}
}
return false;
}
public static bool IsRunTime() {
// Determine if this instance is running against .NET Compact Framework by using the MSCoreLib PublicKeyToken
System.Reflection.Assembly mscorlibAssembly = typeof(int).Assembly;
if ((mscorlibAssembly != null)) {
if (mscorlibAssembly.FullName.ToUpper().EndsWith("969DB8053D3322AC")) {
return true;
}
}
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -