Do you know the guidelines for coping with binaries in domain model? I frequently must connect images along with other files with business objects and also the simple byte[] isn't sufficient for the easiest of cases.

The files:

  • Doesn't have a set size and can be very large thus:
    • Need to be streamed or buffered, ideally in asynchronous manner
    • Should be cached both on server and client to prevent redundant transfer
    • On hard to rely on connections the information transfer can be simply interrupted and needs to be started again - and so the transfer could start not right from the start of file but from arbitrary position.
  • Are handled in a different way compared to relaxation from the data:
    • In web programs aren't area of the page content but they are downloaded by browser individually
    • May well be a black box that's handled by third-party software
    • For performance reasons may not be also saved within the database.

How can we start indicating such files in domain model (or even more particularly, in model classes)? When the relaxation from the model is moved via DTOs and WCF web services and endured with NHibernate within the database, however the files not always so, steps to make the file handling transparent, area of the overall transaction where relevant yet support all that's necessary to allow them to be consumed with web programs, but additionally in regular desktop programs.

For WPF and ASP.Internet the file object must expose some type of Url property that may be data-certain to WPF controls or utilized in IMG or HTML tags. Uploading personal files is much more complicated. Ideally, proper presentation and content practices for example MVVM should be maintained there.

I'm really lost here like me unsatisfied with some of these solutions. An amount you advice?