| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Data.Linq;
|
|---|
| 4 | using System.Linq;
|
|---|
| 5 | using System.Linq.Expressions;
|
|---|
| 6 | using System.Text;
|
|---|
| 7 | using Platnosci.Core.Interface;
|
|---|
| 8 | using Platnosci.Core.Linq;
|
|---|
| 9 |
|
|---|
| 10 | namespace Platnosci.Core.Linq
|
|---|
| 11 | {
|
|---|
| 12 | public sealed class RepositoryPotwierdzeniaEcard : IRepositoryPT
|
|---|
| 13 | {
|
|---|
| 14 | private readonly PlatnosciDataContext _dataContext = new PlatnosciDataContext();
|
|---|
| 15 |
|
|---|
| 16 | public int Count()
|
|---|
| 17 | {
|
|---|
| 18 | return _dataContext.GetTable<PotwierdzeniaEcard>().Count();
|
|---|
| 19 | }
|
|---|
| 20 | public int Count(Expression<Func<PotwierdzeniaEcard, bool>> expression)
|
|---|
| 21 | {
|
|---|
| 22 | return _dataContext.GetTable<PotwierdzeniaEcard>().Count(expression);
|
|---|
| 23 | }
|
|---|
| 24 | public PotwierdzeniaEcard FindOne(int id)
|
|---|
| 25 | {
|
|---|
| 26 | return FindOne(t => t.ORDERNUMBER == id);
|
|---|
| 27 | }
|
|---|
| 28 | public PotwierdzeniaEcard FindOne(Expression<Func<PotwierdzeniaEcard, bool>> expression)
|
|---|
| 29 | {
|
|---|
| 30 | return _dataContext.GetTable<PotwierdzeniaEcard>().Where(expression).SingleOrDefault();
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | public bool TryFindOne(Expression<Func<PotwierdzeniaEcard, bool>> expression, out PotwierdzeniaEcard entity)
|
|---|
| 34 | {
|
|---|
| 35 | entity = FindOne(expression);
|
|---|
| 36 |
|
|---|
| 37 | return (entity != null);
|
|---|
| 38 | }
|
|---|
| 39 | public bool Exists(Expression<Func<PotwierdzeniaEcard, bool>> expression)
|
|---|
| 40 | {
|
|---|
| 41 | var entity = FindOne(expression);
|
|---|
| 42 |
|
|---|
| 43 | return (entity != null);
|
|---|
| 44 | }
|
|---|
| 45 | public IList<PotwierdzeniaEcard> FindAll()
|
|---|
| 46 | {
|
|---|
| 47 | return _dataContext.GetTable<PotwierdzeniaEcard>().ToList();
|
|---|
| 48 | }
|
|---|
| 49 | public IList<PotwierdzeniaEcard> FindAll(Expression<Func<PotwierdzeniaEcard, bool>> expression)
|
|---|
| 50 | {
|
|---|
| 51 | return _dataContext.GetTable<PotwierdzeniaEcard>().Where(expression).ToList();
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | public void Insert(PotwierdzeniaEcard entity)
|
|---|
| 55 | {
|
|---|
| 56 | _dataContext.GetTable<PotwierdzeniaEcard>().InsertOnSubmit(entity);
|
|---|
| 57 | _dataContext.SubmitChanges();
|
|---|
| 58 | }
|
|---|
| 59 | public void Delete(PotwierdzeniaEcard entity)
|
|---|
| 60 | {
|
|---|
| 61 | if (entity != null)
|
|---|
| 62 | {
|
|---|
| 63 | _dataContext.GetTable<PotwierdzeniaEcard>().DeleteOnSubmit(entity);
|
|---|
| 64 | _dataContext.SubmitChanges();
|
|---|
| 65 | }
|
|---|
| 66 | }
|
|---|
| 67 | public void Update(PotwierdzeniaEcard entity)
|
|---|
| 68 | {
|
|---|
| 69 | _dataContext.SubmitChanges();
|
|---|
| 70 | }
|
|---|
| 71 | public IQueryable<PotwierdzeniaEcard> Find(int id)
|
|---|
| 72 | {
|
|---|
| 73 | return _dataContext.GetTable<PotwierdzeniaEcard>().Where(t => t.ORDERNUMBER == id);
|
|---|
| 74 | }
|
|---|
| 75 | public IQueryable<PotwierdzeniaEcard> Find(Expression<Func<PotwierdzeniaEcard, bool>> expression)
|
|---|
| 76 | {
|
|---|
| 77 | return _dataContext.GetTable<PotwierdzeniaEcard>().Where(expression);
|
|---|
| 78 | }
|
|---|
| 79 | public IQueryable<PotwierdzeniaEcard> Find()
|
|---|
| 80 | {
|
|---|
| 81 | return _dataContext.GetTable<PotwierdzeniaEcard>();
|
|---|
| 82 | }
|
|---|
| 83 | }
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|