Skip to content

Commit 7bed9ba

Browse files
committed
Add methods that remove save changes from add to allow for larger inserts
1 parent 5e23957 commit 7bed9ba

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
### CsuChhs.DataTools
22

3+
#### 1.0.3
4+
- Added bulk insert action that removes save changes.
5+
36
#### 1.0.2
47
- Bumped min EF core version to 9.0
58

CsuChhs.DataTools/CsuChhs.DataTools.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
88
<Authors>CHHS Application Development Team</Authors>
9-
<Version>1.0.2</Version>
9+
<Version>1.0.3</Version>
1010
<PackageProjectUrl>https://github.com/csu-chhs/CsuChhs.DataTools</PackageProjectUrl>
1111
<Company>College of Health and Human Sciences</Company>
1212
<PackageId>CsuChhs.DataTools</PackageId>

CsuChhs.DataTools/DAL/EntityRepository.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ public T Add(T entity)
2020
return entity;
2121
}
2222

23+
public T AddBulk(T entity)
24+
{
25+
_dbContext.Set<T>().Add(entity);
26+
return entity;
27+
}
28+
2329
public IQueryable<T> AllQueryable()
2430
{
2531
return _dbContext.Set<T>();
@@ -31,6 +37,11 @@ public void Delete(T entity)
3137
_dbContext.SaveChanges();
3238
}
3339

40+
public void SaveChanges()
41+
{
42+
_dbContext.SaveChanges();
43+
}
44+
3445
public void Update(T entity)
3546
{
3647
_dbContext.Entry(entity).State = EntityState.Modified;

CsuChhs.DataTools/Interfaces/IRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ public interface IRepository<T> where T : BaseModel
88
void Update(T entity);
99
void Delete(T entity);
1010
T Add(T entity);
11+
T AddBulk(T entity);
12+
void SaveChanges();
1113
}
1214
}

0 commit comments

Comments
 (0)