Shard-like pattern using Azure blob storage

20 views
Skip to the first unread message

Alberto

unread,
27 Aug 2019, 19:43:0927/08/2019
to nhusers
I have a "User" entity that has a "ProfilePicture" byte-array property, persisted in a Filestream field on SQL Server.
I would like to make this web application work in an Azure AppService, and It would be great if all binary contents (pictures) are saved inside an Azure blob storage container.
My application works great On-Premises, and I would like to keep everything as is, changing only the binary data persistence behavior.
How can achieve this?

My idea is to create a custom ProxyFactory class that injects Blob storage persistence logic inside entity binary properties' getters and setters (AOP style), and invoke that logic using an event listener. Does this make sense?

Anyway:
1. How can I create a custom ProxyFactory class, and how can I specify it in my NH configuration?
2. Is there a way to create custom proxies using NHibernate, or I have to rely on external libraries (i.e. Castle)?

Thanks a lot,

--
Alberto

Alexander Zaytsev

unread,
27 Aug 2019, 19:56:5227/08/2019
to nhu...@googlegroups.com
Hi,

This has to be done with a custom user type/type. This might give you and idea how it could look like: 

Best Regards,
Alexander 

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nhusers/655e4ac0-8f07-4134-9322-9566cd04b099%40googlegroups.com.

Alberto

unread,
28 Aug 2019, 06:14:3128/08/2019
to nhusers
Thanks Alexander,

I'll give it a look.
Anyway, what do you think about my idea? I'm asking you this also because I see that the "NHibernate.Proxy.DynamicProxy" namespace has been obsoleted; is relying on a third-party proxy library the suggested way from now on?

Thanks again,

--
Alberto

Gunnar Liljas

unread,
28 Aug 2019, 13:05:2428/08/2019
to nhu...@googlegroups.com
I know you want to keep everything as is, but I strongly recommend that you move the ProfilePicture storage to its own "service" instead. 

/G 

Alberto

unread,
29 Aug 2019, 07:51:5429/08/2019
to nhusers
I agree, and it's what I'm trying to do.
The "ProfilePicture" property is of type "Picture", who's a class (a Value Object, actually) that has a business meaning in my domain. Under the hood, it simply wraps a byte array, but it has also some business logic inside.
With "keep everything as is" I mean keep my domain logic as is; I would like to change only the persistence logic, and let NHibernate deal with Blob Storage in a transparent way.

Alberto
Reply all
Reply to author
Forward
0 new messages