using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary> /// CarDA 的摘要說明 /// </summary> public class CarDA { private DataClassesDataContext Context; public CarDA() { Context=new DataClassesDataContext (); } public List<Car>Select() { return Context.Car.ToList(); } public Car Select(string code) { return Context.Car.Where(p => p.Code == code).First(); } public void Delete(string code) { Context.Car.DeleteOnSubmit(Context.Car.Where(p => p.Code == code).First()); Context.SubmitChanges(); } public void update(Car data) { Car dt = Context.Car.Where(p => p.Code == data.Code).First(); dt.Brand = data.Brand; dt.Name = data.Name; Context.SubmitChanges(); } public void insert(Car data) { Context.Car.InsertOnSubmit(data); Context.SubmitChanges(); } }