views:

260

answers:

1

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?

+4  A: 

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

ArsenMkrt
+1 - This is exactly what I would do, but I would hope there was a better way of doing this
MPritch
+1 +answer credit - yeah, not very graceful, but very little performance penalty. Just added a computed column and it works fine!
Shaul
this may halp help too, http://forums.asp.net/p/974397/1240722.aspx#1240722
ArsenMkrt