-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitOfWork.cs
More file actions
38 lines (35 loc) · 795 Bytes
/
UnitOfWork.cs
File metadata and controls
38 lines (35 loc) · 795 Bytes
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
using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppLibrary
{
public class UnitOfWork : IUnitOfWork
{
private static string conStr = null;
public SQLiteTransaction transaction { get; set; }
public SQLiteConnection connection { get; set; }
public UnitOfWork(string sDBAliasName)
{
conStr = new DBHelper().GetConnectionString(sDBAliasName);
connection = new SQLiteConnection(conStr);
}
public void BeginTransaction()
{
connection.Open();
transaction = connection.BeginTransaction();
}
public void Commit()
{
transaction.Commit();
connection.Dispose();
}
public void Rollback()
{
transaction.Rollback();
connection.Dispose();
}
}
}