Skip to content

Commit

Permalink
Merge pull request #2 from csu-chhs/remove-single
Browse files Browse the repository at this point in the history
Removing .Single
  • Loading branch information
dstegelman authored Jun 26, 2024
2 parents 72e025b + 55e9605 commit 0b78139
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
.idea/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### CsuChhs.DataTools

#### 1.0.1
- Removed .Single, .SingleOrNull and its Async partners.
2 changes: 1 addition & 1 deletion CsuChhs.DataTools/CsuChhs.DataTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>CHHS Application Development Team</Authors>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<PackageProjectUrl>https://github.com/csu-chhs/CsuChhs.DataTools</PackageProjectUrl>
<Company>College of Health and Human Sciences</Company>
<PackageId>CsuChhs.DataTools</PackageId>
Expand Down
24 changes: 0 additions & 24 deletions CsuChhs.DataTools/DAL/EntityRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,6 @@ public void Delete(T entity)
_dbContext.SaveChanges();
}

public T GetSingle(int id)
{
return _dbContext.Set<T>()
.Single(s => s.ID == id);
}

public async Task<T> GetSingleAsync(int id)
{
return await _dbContext.Set<T>()
.SingleAsync(s => s.ID == id);
}

public T? GetSingleOrNull(int id)
{
return _dbContext.Set<T>()
.SingleOrDefault(s => s.ID == id);
}

public async Task<T?> GetSingleOrNullAsync(int id)
{
return await _dbContext.Set<T>()
.SingleOrDefaultAsync(s => s.ID == id);
}

public void Update(T entity)
{
_dbContext.Entry(entity).State = EntityState.Modified;
Expand Down
4 changes: 0 additions & 4 deletions CsuChhs.DataTools/Interfaces/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ namespace CsuChhs.DataTools.Interfaces
{
public interface IRepository<T> where T : BaseModel
{
T GetSingle(int id);
T? GetSingleOrNull(int id);
Task<T> GetSingleAsync(int id);
Task<T?> GetSingleOrNullAsync(int id);
IQueryable<T> AllQueryable();
void Update(T entity);
void Delete(T entity);
Expand Down

0 comments on commit 0b78139

Please sign in to comment.