NHAgkRepository.cs
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ControlPanel.Interfaces.Reposytorys;
using ControlPanel.Models;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Criterion;
using NHibernate.Tool.hbm2ddl;
using FluentNHibernate.Cfg.Db;
using FluentNHibernate.Automapping;
using ControlPanel.Interfaces.Reposytorys;
namespace ControlPanel.NHInplimentRepository
{
public class NHAgkRepository : NHMainRepository<Agk>, IAgkRepository
{
int IAgkRepository.Count()
{
int count=0;
using (ISession session = GetNHBSession())
{
session.BeginTransaction();
var rowCount = session.CreateCriteria(typeof(Agk))
.SetProjection(Projections.RowCount()).FutureValue<Int32>();
try
{
count = rowCount.Value;
}
catch (Exception)
{
}
session.Transaction.Commit();
}
return count;
}
IList<Agk> IAgkRepository.GetLog(int start, int limit)
{
IList<Agk> list;
using (ISession session = GetNHBSession())
{
session.BeginTransaction();
list = session.CreateCriteria(typeof(Agk))
.SetFirstResult(start)
.SetMaxResults(limit - start + 1)
.List<Agk>();
session.Transaction.Commit();
}
return list;
}
Agk IAgkRepository.GetAgkByNumber(int number)
{
Agk agk = null ;
using (ISession session = GetNHBSession())
{
session.BeginTransaction();
var result = session.CreateCriteria(typeof(Agk))
.Add(Restrictions.Eq("number", number))
.List<Agk>();
agk=result.First() as Agk;
session.Transaction.Commit();
}
return agk;
}
}
}