diff options
| author | crupest <crupest@outlook.com> | 2022-12-21 16:42:07 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-12-21 16:42:07 +0800 | 
| commit | a5ddd51b4b01ddd2494fcde3cdb63da6819a8766 (patch) | |
| tree | f0f9f56609f82e858489d3852165844b2f0434e2 | |
| parent | 673aeab45542400efcbbe7f400c806af7b336df1 (diff) | |
| download | crupest-a5ddd51b4b01ddd2494fcde3cdb63da6819a8766.tar.gz crupest-a5ddd51b4b01ddd2494fcde3cdb63da6819a8766.tar.bz2 crupest-a5ddd51b4b01ddd2494fcde3cdb63da6819a8766.zip  | |
Develop secret api. v55
3 files changed, 11 insertions, 2 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs index b7b7ccd..762e3a8 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons.Tests/Crud/CrudServiceTest.cs @@ -41,6 +41,9 @@ public class CrudServiceTest          Assert.Equal(18, entity.Age);          Assert.Null(entity.Height);          Assert.NotEmpty(entity.Secret); + +        var count = _crudService.GetCount(); +        Assert.Equal(1, count);      } diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs index abae774..eab8567 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs @@ -61,6 +61,12 @@ public class CrudService<TEntity> : IDisposable where TEntity : class          return result;      } +    public int GetCount() +    { +        var result = _table.SelectCount(_dbConnection); +        return result; +    } +      public TEntity GetByKey(object key)      {          var result = _table.Select<TEntity>(_dbConnection, null, WhereClause.Create().Eq(_table.KeyColumn.ColumnName, key)).SingleOrDefault(); diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs index 62ebc4a..6a88ee1 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs @@ -436,8 +436,8 @@ CREATE TABLE {tableName}(      public virtual int SelectCount(IDbConnection dbConnection, IWhereClause? where = null, IOrderByClause? orderBy = null, int? skip = null, int? limit = null)      {          var (sql, parameters) = GenerateSelectSql("COUNT(*)", where, orderBy, skip, limit); -        return dbConnection.QuerySingle<int>(sql, parameters); - +        var result = dbConnection.QuerySingle<int>(sql, ConvertParameters(parameters)); +        return result;      }      public virtual TResult MapDynamicTo<TResult>(dynamic d)  | 
