I'm using c#,wpf and mvvm.

During my datagrid every row has within the last cell a ListBox with documents associated with this row that we call a period of time.

The consumer can also add documents to each period.

I wish to display for each document the file type icon(16x16) and also the document`s title.

The file type icon provides me with a little of the headache.

I don't know wether I ought to save every documents file type icon like .DOC within the database just because a day has maybe 10 periods each one has -Doctor files attached thus I save 20 symbols within the database that are 19 occasions redundant...

Most stuff my user will attach are Office file types like .xls,.doc,.pdf,images,zip/rar thats it I suppose.

Another but technically more complex is always to save the initial file type icon as encoded base-64 string inside a XML file using the file type extension as key/value pair.

The xml is loaded once inside a dictionary once at application launch

<Extension ext="doc" base64string="ff5598sdfusd98fjs9df98sd9f" />
<Extension ext="docx" base64string="ff5498sdfusd98fjs9df98sd9f" />
<Extension ext="xls" base64string="ff9548sdfdsfdfusd98fjs9df98sd9f" />
<Extension ext="xlsx" base64string="ff98sfdfddfusd98fjs9df98sd9f" />
<Extension ext="pdf" base64string="ff98fdfdsdfusd98fjs9df98sd9f" />
<Extension ext="zip" base64string="ff98dfdfsdfusd98fjs9df98sd9f" />
<Extension ext="rar" base64string="fffdf98sdfusd98fjs9df98sd9f" />

Whenever a document comes lower the database I look into the file extension within the file title and retrieve the dictionary to obtain the base64 string for that file. I possibly could still in some way implement a caching mechanism for that file type base64 string so I don't decode them each time I recieve b .doctor file...

Perhaps you have a quite different/better ? idea, please tell me or make information on advantages/disadvantes of database/xml saving :)

Always avoid keeping binary images in databases. query and covertion are gone heads. the easiest way with this particular choice is to help keep all ur photos as resourcess and the resource title saved towards the database .. u can perform tht by have a enum from the resource names and parse the (eNUM.PARSE) names at onrowdatabound as source binding to cell template of the datagrid row. the cell could have a picture as template content.

For those who have couple of file types and a large number of files, its better that you simply keep file types like a file_type_master type of database or XML file and load it once when you utilize it everywhere. However it holds good when there's a great downside when it comes to loading and usage. Otherwise you may also do type of caching.