Pokaż
Ignoruj:
Data:
2009-11-03 16:06:42 (16 years ago)
Autor:
alina
Opis:

re #215

Pliki:
1 zmodyfikowane

Legenda:

Bez zmian
Dodane
Usunięte
  • trunk/eCard/eCardMVC/Platnosci.Core/Linq/Repository.cs

    r867 r870  
    1515    /// <typeparam name="T">The generic type representing the entity we are dealing with</typeparam> 
    1616    /// <remarks>We use a 1 to 1 mapping of entity -> SQL table</remarks> 
    17     public sealed class Repository<T> : IRepository<T> 
    18       where T : class, IIdentifiable 
     17    public class Repository<T> : IRepository<T> where T : class, IIdentifiable 
    1918    { 
    20         private readonly PlatnosciDataContext _dataContext = new PlatnosciDataContext(); 
     19       // private readonly PlatnosciDataContext _dataContext = new PlatnosciDataContext(); 
     20        //private PlatnosciDataContext _dataContext = new PlatnosciDataContext(); 
     21        protected readonly IDataContext _dataContext; 
    2122 
     23        public Repository(IDataContext dataContext) 
     24        { 
     25            _dataContext = dataContext; 
     26        }   
    2227        public int Count() 
    2328        { 
     
    5762            return _dataContext.GetTable<T>().Where(expression).ToList(); 
    5863        } 
    59  
    6064        public void Insert(T entity) 
    61         { 
    62             //DataContext.GetTable<T>().InsertOnSubmit(entity); 
    63             //DataContext.SubmitChanges(); 
    64  
    65             //using (DataContext dc = new WierszowkiDataContext()) 
    66             //{ 
    67                 _dataContext.GetTable<T>().InsertOnSubmit(entity); 
    68                 _dataContext.SubmitChanges(); 
    69             //} 
    70         } 
     65            { 
     66                _dataContext.Insert(entity);             
     67            } 
    7168        public void Delete(T entity) 
    7269        { 
    73             if (entity != null) 
    74             { 
    75                 _dataContext.GetTable<T>().DeleteOnSubmit(entity); 
    76                 _dataContext.SubmitChanges(); 
    77             } 
     70            _dataContext.Insert(entity); 
    7871        } 
    7972        public void Update(T entity) 
     
    9285        { 
    9386            return _dataContext.GetTable<T>(); 
    94         }        
     87        } 
     88        public IQueryable<vPlatnosciEcard> FindInvoiceByNipNumber(string nip, string numer) 
     89        { 
     90            return _dataContext.FindInvoiceByNipNumber(nip, numer); 
     91        } 
     92        public IQueryable<vPlatnosciEcard> FindInvoiceById(int id) 
     93        { 
     94            return _dataContext.FindInvoiceById(id); 
     95        } 
     96        public List<PotwierdzeniaEcard> FindItemsByIdFaktury(int idFaktury) 
     97        { 
     98            return _dataContext.FindItemsByIdFaktury(idFaktury); 
     99        } 
    95100    } 
    96101}