I have a database table FILES which contains columns; FILE_ID, FILE_NAME, MIME_TYPE and FILE_DATA. The FILE_DATA column is SQL Server Image, Initially I had a single C# class and mapping to represent a File. I found that queries were quite slow because it always read the FILE_DATA image even though I often only needed the header information. I split up the C# class and mapping into two seperate classes and mappings. File maps columns FILE_ID, FILE_NAME and MIME_TYPE and also has a many-to-one association with FileData. FileData contains columns FILE_ID and FILE_DATA. Both mappings map to the same database table FILES. Now queries for File are much faster but I have problems inserting a File. It seems to be trying to insert an seperate row for FileData but I need them to share the same row and insert as one. Is this possible or must I have two seperate rows in two seperate tables?
|