< Summary

Information
Class: CounterDrone.Core.Repository.BaseRepository<T>
Assembly: CounterDrone.Core
File(s): C:\Users\Tellme\apps\CounterDroneBackend\src\CounterDrone.Core\Repository\BaseRepository.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 46
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetById(...)100%11100%
GetAll()100%11100%
Insert(...)100%11100%
Update(...)100%11100%
Delete(...)100%11100%
InsertAll(...)100%11100%

File(s)

C:\Users\Tellme\apps\CounterDroneBackend\src\CounterDrone.Core\Repository\BaseRepository.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using SQLite;
 3
 4namespace CounterDrone.Core.Repository
 5{
 6    /// <summary>泛型仓储基类</summary>
 7    public abstract class BaseRepository<T> where T : new()
 8    {
 9        protected readonly SQLiteConnection Db;
 10
 27911        protected BaseRepository(SQLiteConnection db)
 27912        {
 27913            Db = db;
 27914        }
 15
 16        public virtual T GetById(object id)
 30117        {
 30118            return Db.Find<T>(id);
 30119        }
 20
 21        public virtual List<T> GetAll()
 422        {
 423            return Db.Table<T>().ToList();
 424        }
 25
 26        public virtual int Insert(T entity)
 13627        {
 13628            return Db.Insert(entity);
 13629        }
 30
 31        public virtual int Update(T entity)
 9132        {
 9133            return Db.Update(entity);
 9134        }
 35
 36        public virtual int Delete(object id)
 537        {
 538            return Db.Delete<T>(id);
 539        }
 40
 41        public virtual void InsertAll(IEnumerable<T> entities)
 3442        {
 3443            Db.InsertAll(entities);
 3444        }
 45    }
 46}