SQL server image datatype with > 10 MB data

Posts   
 
    
JohnRLewis avatar
JohnRLewis
User
Posts: 27
Joined: 30-Aug-2004
# Posted on: 22-Nov-2004 17:07:18   

I have an image field in my database that contains more than 10MB of data. The existing way that I access this data in order not to consume too much data is by using the GetBytes method of the SqlDataReader class in a loop, writing out chunks to a file.

I cannot find how to get the equivalent functionality with llblgen. Is there a way that I do not see?

JohnRLewis avatar
JohnRLewis
User
Posts: 27
Joined: 30-Aug-2004
# Posted on: 22-Nov-2004 17:55:32   

At least help me find a way to exclude that field from the Entity so that I don't have to retrieve that field. Then I can add my own method for retrieving that field in my business logic.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 22-Nov-2004 18:27:34   

At the moment (it will be added to the next upgrade to the designer) you can't do this in the designer, what you can do is a trick in code (if you're fetching a single entity) by copying for example the first field at the spot of the blob field:

entity.Fields[(int)EFieldIndex.BlobField] = entity.Fields[0];

Don't do this with PK fields, pick a field which isn't a pk field. If you're using selfservicing, you can't use this with fetching a collection. If you're using adapter, you can, by creating a special factory class for this entity which uses the trick above to make sure the blob field isn't turning up in the select list

However, for now the 'best' workaround is to use a typed list for fetching (create a typed list without the blob field)

Frans Bouma | Lead developer LLBLGen Pro
JohnRLewis avatar
JohnRLewis
User
Posts: 27
Joined: 30-Aug-2004
# Posted on: 22-Nov-2004 18:51:23   

When can I expect the next version of the designer? The answer will determine how I design the database. If the timeframe is soon enough, I'll design the database in the way I think is right, and code a hack for now.

Otherwise, I'll seperate the image field off into its own table, and not include that table as an entity. But, I'd rather keep the meta data about the blob in the same table as the blob itself.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 22-Nov-2004 21:08:51   

JohnRLewis wrote:

When can I expect the next version of the designer? The answer will determine how I design the database. If the timeframe is soon enough, I'll design the database in the way I think is right, and code a hack for now.

Otherwise, I'll seperate the image field off into its own table, and not include that table as an entity. But, I'd rather keep the meta data about the blob in the same table as the blob itself.

The designer will be upgraded in 2 phases. Phase one has to be complete early january which will have multi-catalog support, an updated typedlist editor and better refresher/project creator functionality, the second phase has to be completed at the end of february/early march.

Frans Bouma | Lead developer LLBLGen Pro
dion avatar
dion
User
Posts: 11
Joined: 23-Apr-2004
# Posted on: 24-Nov-2004 23:44:49   

Hi Frans,

You wrote that the next statement can be used to exclude a field in an Entity from being fetched:

entity.Fields[(int)EFieldIndex.BlobField] = entity.Fields[0];

Can you explain how to implement this? Should I create an empty Entity first?

dion avatar
dion
User
Posts: 11
Joined: 23-Apr-2004
# Posted on: 24-Nov-2004 23:55:01   

When I try your code-statement on the Employees table in Northwind I get an internal error:

Item has already been added. Key in dictionary: "EmployeeID" Key being added: "EmployeeID"

I also tried other fields than entity.Fields[0], but I got the same error...

dion avatar
dion
User
Posts: 11
Joined: 23-Apr-2004
# Posted on: 25-Nov-2004 00:34:34   

Ah, I finally managed to exclude a field in an Entity from being fetched, by using next code:


//Create empty EmployeesEntity
EmployeesEntity employee = new EmployeesEntity();

//Change name of field #1 (= "LastName") to "dummy"
employee.Fields[1].Name = "dummy";

//Set Photo-field (containing big image) to LastName field
//Because name was changed, ORM's internal hashtable won't give problems anymore
employee.Fields[(int)Northwind.EmployeesFieldIndex.Photo] = employee.Fields[1];

//Change back name of LastName field
employee.Fields[1].Name = employee.Fields[1].SourceColumnName;

//Now fetch Employee with ID 1. 
//Look at the resulting SQL in SQL Profiler (LastName is fetched twice, but Photo isn't
employee.FetchUsingPK(1); 
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 25-Nov-2004 09:15:54   

Sorry for this inconvenience, I indeed made a mistake: you should have renamed/reindexed the column, the idea is the same: make the field fetch the same data again. simple_smile

Frans Bouma | Lead developer LLBLGen Pro