Skip to content

sqllite查询完释放对象文件被占用 #2004

Closed
@liuweishow

Description

@liuweishow

问题描述及重现代码:

3.2.825版本,sqllite 使用using创建IFreeSql 对象后,方法执行完毕之后,文件还是被占用,需要Dispose才行
public async Task<Tuple<long, List>> GetTablePageAsync(string fileName, string tableName, PageCondition pageCondition, Expression<Func<T1, bool>>? exp = null, Expression<Func<T1, object>>? orderBy = null, bool descending = false) where T1 : class, ISqliteEntity
{
string tableName2 = tableName;
_sqliteService.RegisterDataSource(fileName);
using IFreeSql freeSql = _freeSqlCloudService.Use(fileName);
if (!freeSql.DbFirst.ExistsTable(tableName2))
{
return Tuple.Create(0L, new List());
}

    ISelect<T1> select = freeSql.Select<T1>().AsTable((Type type, string old) => tableName2).WhereIf(exp != null, exp);
    return Tuple.Create(await select.CountAsync(), await select.OrderByDescending(descending, orderBy).Page(pageCondition.PageIndex, pageCondition.PageSize).ToListAsync());
}

数据库版本

sqllite

3.2.825

.net framework/. net core 8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions