获取不包含 Blob 本身的 Blob 大小

发布于 2024-08-21 10:10:40 字数 294 浏览 3 评论 0原文

我有一个表,其中有一个代表文件的 blob 列。 我想运行一个 LinqToSql 查询,返回文件的名称和描述以及文件大小...但为了不影响性能,我显然不想下载整个 blob!

var q = from f in MyFiles
        select new {f.Name, f.Description, f.Blob.Length};

似乎从数据库中提取整个 blob,然后计算其在本地内存中的长度。

我怎样才能做到这一点,以便我只获取 blob 大小,而不下载整个 blob?

I have a table that has a blob column representing a file.
I'd like to run a LinqToSql query that returns a name and description of the file, along with the file size... but in the interests of not killing performance, I obviously don't want to download the whole blob!

var q = from f in MyFiles
        select new {f.Name, f.Description, f.Blob.Length};

appears to pull the entire blob from the DB, then calculate its length in local memory.

How can I do this so that I only get the blob size, without downloading the entire blob?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

つ低調成傷 2024-08-28 10:10:40

我认为您的情况最好的选择是将文件存储到数据库时将 blob 大小存储在单独的列中。

I think the best choose in your case is to store blob size in the separate column, when storing file to database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文