Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
liuweishow opened this issue Apr 14, 2025 · 4 comments
Closed

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

liuweishow opened this issue Apr 14, 2025 · 4 comments

Comments

@liuweishow
Copy link

问题描述及重现代码:

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

@2881099
Copy link
Collaborator

2881099 commented Apr 14, 2025

要释放文件才会释放。

@liuweishow
Copy link
Author

要释放文件才会释放。

如何释放呢,请教

@2881099
Copy link
Collaborator

2881099 commented Apr 15, 2025

FreeSql.Cloud 2.0.1

cloud.RemoveRegister(key, true);

@liuweishow
Copy link
Author

感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants