Guest User

MobileCarrier Model

a guest
Mar 29th, 2011
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3.  
  4. namespace Yes.Models
  5. {
  6.     public partial class MobileCarrier
  7.     {
  8.         YesDataContext dc = new YesDataContext();
  9.  
  10.         public MobileCarrier GetMobileCarrier(int id)
  11.         {
  12.             return (from mc in this.dc.MobileCarriers where mc.ID == id select mc).SingleOrDefault();
  13.  
  14.         }
  15.  
  16.         public IEnumerable<MobileCarrier> GetAll()
  17.         {
  18.             return from mc in this.dc.MobileCarriers orderby mc.Name select mc;
  19.         }
  20.  
  21.         public void Insert()
  22.         {
  23.             this.dc.MobileCarriers.InsertOnSubmit(this);
  24.             this.dc.SubmitChanges();
  25.         }
  26.  
  27.         public void Update()
  28.         {
  29.             this.dc.MobileCarriers.Attach(this);
  30.             this.dc.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, this);
  31.             this.dc.SubmitChanges();
  32.         }
  33.  
  34.         public void Delete()
  35.         {
  36.             this.dc.MobileCarriers.Attach(this);
  37.             this.dc.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, this);
  38.             this.dc.MobileCarriers.DeleteOnSubmit(this);
  39.             this.dc.SubmitChanges();
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment