⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customersstore.cs

📁 简单的cI真的是很简单 你想要就下载吧
💻 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 + -