?? customersstore.cs
字號:
?using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VinciDataAccess.Linq;
using VinciDataAccess.Entity;
using System.Collections;
namespace VinciDataAccess.DataAccess
{
public class CustomersStore
{
private CustomersDataContext _customersDataContext = null;
public CustomersStore()
{
_customersDataContext = new CustomersDataContext();
}
/// <summary>
/// Define Method CustomersObjectToEntity
/// Return CustomerEntity
/// </summary>
/// <param name="customer"></param>
/// <returns></returns>
private CustomersEntity CustomersObjectToEntity(Customers customer)
{
VinciDataAccess.Entity.CustomersEntity customerEntity = new VinciDataAccess.Entity.CustomersEntity();
customerEntity.CustomerID = customer.CustomerID;
customerEntity.CompanyName = customer.CompanyName;
customerEntity.ContactName = customer.ContactName;
customerEntity.ContactTitle = customer.ContactTitle;
customerEntity.Address = customer.Address;
customerEntity.City = customer.City;
customerEntity.RegionID = customer.RegionID;
customerEntity.PostalCode = customer.PostalCode;
customerEntity.Country = customer.Country;
customerEntity.Fax = customer.Fax;
customerEntity.Phone = customer.Phone;
return customerEntity;
}
/// <summary>
/// Get List Of Customers
/// </summary>
/// <returns></returns>
public CustomersCollection GetCustomersList()
{
CustomersCollection customersList = new CustomersCollection();
IEnumerable<Customers> customers = from customer in this._customersDataContext.Customers
orderby customer.CustomerID
select customer;
foreach(Customers customer in customers)
{
customersList.Add(this.CustomersObjectToEntity(customer));
}
return customersList;
}
/// <summary>
/// Get Single Customer Information
/// Select It By CustomerID
/// </summary>
/// <param name="customerID"></param>
/// <returns></returns>
public CustomersEntity GetCustomerInfo(int customerID )
{
CustomersEntity customersEntity = new CustomersEntity();
IEnumerable<Customers> customers = from customer in this._customersDataContext.Customers
where customer.CustomerID ==customerID
select customer;
foreach(Customers customer in customers)
{
customersEntity= this.CustomersObjectToEntity(customer);
}
return customersEntity;
}
//public ArrayList GetCustomerIDByCustomerName(string customerName)
//{
// ArrayList customerIDList = new ArrayList();
// var customerid = _customersDataContext.ExecuteQuery<Customers>("select CustomerID from Customers where ContactName like"+"'"+"%"+customerName+"%"+"'");
// foreach (var id in customerid)
// {
// customerIDList.Add(id.CustomerID);
// }
// return customerIDList;
// }
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -