Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
use custom IRepository interface in SharpModelBinder
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Paul Hinett  
View profile  
 More options Jan 11 2011, 1:05 pm
From: "Paul Hinett" <p...@ukcreativedesigns.com>
Date: Tue, 11 Jan 2011 18:05:12 -0000
Local: Tues, Jan 11 2011 1:05 pm
Subject: use custom IRepository interface in SharpModelBinder

Hi,

I am setting up my project to use multi-tenancy from this fantastic article
which popped up today:

http://www.yellowfeather.co.uk/2011/01/multi-tenancy-on-sharp-archite...

However there is a problem which doesn't seemed to be addressed which is the
SharpModelBinder.

For the multi-tenant repositories to work they need to inherited from a
custom class called MultiTenantRepository<>.

However the SharpModelBinder uses it's own IRepositoryWithTypeId<>, is there
an easy way to override this without changing the Sharp source code and
re-compiling?

Thank you.

Paul


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Richards  
View profile  
 More options Jan 12 2011, 7:48 am
From: Chris Richards <chris.richa...@yellowfeather.co.uk>
Date: Wed, 12 Jan 2011 04:48:34 -0800 (PST)
Local: Wed, Jan 12 2011 7:48 am
Subject: Re: use custom IRepository interface in SharpModelBinder
Hi Paul,

I've forked S#arp Architecture and made some minor changes to allow
different methods of getting the session factory key.

Basically I've created an interface ISessionFactoryKeyProvider to hide
the details of getting the session factory key. The default
implementation I've added, DefaultSessionFactoryKeyProvider, uses the
existing SessionFactoryAttribute so the only change required to
existing application is to register DefaultSessionFactoryKeyProvider
in the container. To use a different method it is just a case of
providing and registering your own implementation of
ISessionFactoryKeyProvider.

I've made a pull request (https://github.com/sharparchitecture/Sharp-
Architecture/pull/1) so hopefully this will make it into the mainline
at some point in the future.

These changes simplify adding multi-tenancy to an app. The
MultiTenenatRepository from my post is no longer required and the
binder should now work. The custom TransactionAttribute is also no
longer required. The sample project https://github.com/yellowfeather/SharpArchitecture-MultiTenant
has been updated to use my forked version of S#arp Architecture.

Blog post coming later in the week.

Cheers,
Chris

On Jan 11, 6:05 pm, "Paul Hinett" <p...@ukcreativedesigns.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jan 12 2011, 5:57 pm
From: Paul <p...@ukcreativedesigns.com>
Date: Wed, 12 Jan 2011 14:57:22 -0800 (PST)
Local: Wed, Jan 12 2011 5:57 pm
Subject: Re: use custom IRepository interface in SharpModelBinder
Thank you so much, I attempted this myself last night but went the
wrong way about it. These seems much more elegant!

1 question though, I have created a custom repository called
ITenantRepository with a function to return all tenants and eager load
some config settings for each config.

But the tenantRepository is trying to use a session factory for one of
my tenants instead of the default...how can i override the factory key
for this repository...I may be overlooking something simple here.

Thank you for your efforts!

Paul

On Jan 12, 12:48 pm, Chris Richards


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Richards  
View profile  
 More options Jan 12 2011, 6:29 pm
From: Chris Richards <chris.richa...@yellowfeather.co.uk>
Date: Wed, 12 Jan 2011 15:29:47 -0800 (PST)
Local: Wed, Jan 12 2011 6:29 pm
Subject: Re: use custom IRepository interface in SharpModelBinder
That is something I hadn't considered, if you're trying to access the
master database whilst responding to a request on a subdomain it will
provide the session factory key for the tenant. Will have a think how
best to solve it and post an update.

As a workaround, you can override the Session get method to use
NHibernateSession.DefaultFactoryKey.

Chris

On Jan 12, 10:57 pm, Paul <p...@ukcreativedesigns.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Richards  
View profile  
 More options Jan 12 2011, 7:04 pm
From: Chris Richards <chris.richa...@yellowfeather.co.uk>
Date: Wed, 12 Jan 2011 16:04:20 -0800 (PST)
Local: Wed, Jan 12 2011 7:04 pm
Subject: Re: use custom IRepository interface in SharpModelBinder
I think the best way to solve this is to reinstate the
IMultiTenantRepository marker interface, add this to the appropriate
repositories and update MultiTenantSessionFactoryKeyProvider so that
it checks for the implementation of this interface. If it is
implemented then attempt to get the factory key from the tenant
context otherwise just return NHibernateSession.DefaultFactoryKey.

I'll test this tomorrow and update my sample project.

Chris

On Jan 12, 11:29 pm, Chris Richards


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Seif Attar  
View profile  
 More options Jan 13 2011, 3:58 am
From: "Seif Attar" <i...@seifattar.net>
Date: Thu, 13 Jan 2011 08:58:15 +0000
Local: Thurs, Jan 13 2011 3:58 am
Subject: Re: use custom IRepository interface in SharpModelBinder

Thanks for sharing this Chris, i think this would make a good addition to contrib, what do you guys think?

On 13 Jan 2011 00:04, Chris Richards &lt;chris.richa...@yellowfeather.co.uk&gt; wrote:

I think the best way to solve this is to reinstate the

IMultiTenantRepository marker interface, add this to the appropriate

repositories and update MultiTenantSessionFactoryKeyProvider so that

it checks for the implementation of this interface. If it is

implemented then attempt to get the factory key from the tenant

context otherwise just return NHibernateSession.DefaultFactoryKey.

I'll test this tomorrow and update my sample project.

Chris

On Jan 12, 11:29&nbsp;pm, Chris Richards

&lt;chris.richa...@yellowfeather.co.uk&gt; wrote:

&gt; That is something I hadn't considered, if you're trying to access the

&gt; master database whilst responding to a request on a subdomain it will

&gt; provide the session factory key for the tenant. Will have a think how

&gt; best to solve it and post an update.

&gt;

&gt; As a workaround, you can override the Session get method to use

&gt; NHibernateSession.DefaultFactoryKey.

&gt;

&gt; Chris

&gt;

&gt; On Jan 12, 10:57&nbsp;pm, Paul &lt;p...@ukcreativedesigns.com&gt; wrote:

&gt;

&gt;

&gt;

&gt;

&gt;

&gt;

&gt;

&gt; &gt; Thank you so much, I attempted this myself last night but went the

&gt; &gt; wrong way about it. These seems much more elegant!

&gt;

&gt; &gt; 1 question though, I have created a custom repository called

&gt; &gt; ITenantRepository with a function to return all tenants and eager load

&gt; &gt; some config settings for each config.

&gt;

&gt; &gt; But the tenantRepository is trying to use a session factory for one of

&gt; &gt; my tenants instead of the default...how can i override the factory key

&gt; &gt; for this repository...I may be overlooking something simple here.

&gt;

&gt; &gt; Thank you for your efforts!

&gt;

&gt; &gt; Paul

&gt;

&gt; &gt; On Jan 12, 12:48&nbsp;pm, Chris Richards

&gt;

&gt; &gt; &lt;chris.richa...@yellowfeather.co.uk&gt; wrote:

&gt; &gt; &gt; Hi Paul,

&gt;

&gt; &gt; &gt; I've forked S#arp Architecture and made some minor changes to allow

&gt; &gt; &gt; different methods of getting the session factory key.

&gt;

&gt; &gt; &gt; Basically I've created an interface ISessionFactoryKeyProvider to hide

&gt; &gt; &gt; the details of getting the session factory key. The default

&gt; &gt; &gt; implementation I've added, DefaultSessionFactoryKeyProvider, uses the

&gt; &gt; &gt; existing SessionFactoryAttribute so the only change required to

&gt; &gt; &gt; existing application is to register DefaultSessionFactoryKeyProvider

&gt; &gt; &gt; in the container. To use a different method it is just a case of

&gt; &gt; &gt; providing and registering your own implementation of

&gt; &gt; &gt; ISessionFactoryKeyProvider.

&gt;

&gt; &gt; &gt; I've made a pull request (https://github.com/sharparchitecture/Sharp-

&gt; &gt; &gt; Architecture/pull/1) so hopefully this will make it into the mainline

&gt; &gt; &gt; at some point in the future.

&gt;

&gt; &gt; &gt; These changes simplify adding multi-tenancy to an app. The

&gt; &gt; &gt; MultiTenenatRepository from my post is no longer required and the

&gt; &gt; &gt; binder should now work. The custom TransactionAttribute is also no

&gt; &gt; &gt; longer required. The sample projecthttps://github.com/yellowfeather/SharpArchitecture-MultiTenant

&gt; &gt; &gt; has been updated to use my forked version of S#arp Architecture.

&gt;

&gt; &gt; &gt; Blog post coming later in the week.

&gt;

&gt; &gt; &gt; Cheers,

&gt; &gt; &gt; Chris

&gt;

&gt; &gt; &gt; On Jan 11, 6:05&nbsp;pm, "Paul Hinett" &lt;p...@ukcreativedesigns.com&gt; wrote:

&gt;

&gt; &gt; &gt; &gt; Hi,

&gt;

&gt; &gt; &gt; &gt; I am setting up my project to use multi-tenancy from this fantastic article

&gt; &gt; &gt; &gt; which popped up today:

&gt;

&gt; &gt; &gt; &gt;http://www.yellowfeather.co.uk/2011/01/multi-tenancy-on-sharp-archite...

&gt;

&gt; &gt; &gt; &gt; However there is a problem which doesn't seemed to be addressed which is the

&gt; &gt; &gt; &gt; SharpModelBinder.

&gt;

&gt; &gt; &gt; &gt; For the multi-tenant repositories to work they need to inherited from a

&gt; &gt; &gt; &gt; custom class called MultiTenantRepository&lt;&gt;.

&gt;

&gt; &gt; &gt; &gt; However the SharpModelBinder uses it's own IRepositoryWithTypeId&lt;&gt;, is there

&gt; &gt; &gt; &gt; an easy way to override this without changing the Sharp source code and

&gt; &gt; &gt; &gt; re-compiling?

&gt;

&gt; &gt; &gt; &gt; Thank you.

&gt;

&gt; &gt; &gt; &gt; Paul

--

You received this message because you are subscribed to the Google Groups "S#arp Architecture" group.

To post to this group, send email to sharp-architecture@googlegroups.com.

To unsubscribe from this group, send email to sharp-architecture+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sharp-architecture?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Howard van Rooijen  
View profile  
 More options Jan 13 2011, 4:46 am
From: Howard van Rooijen <howard.vanrooi...@gmail.com>
Date: Thu, 13 Jan 2011 09:46:52 +0000
Local: Thurs, Jan 13 2011 4:46 am
Subject: Re: use custom IRepository interface in SharpModelBinder

We could include some of the core interfaces into the main SA project - if
this makes it easier for the rest of the MT code to be a "bolt on feature"
rather than a source code integration task?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Richards  
View profile  
 More options Jan 13 2011, 8:52 am
From: Chris Richards <chris.richa...@yellowfeather.co.uk>
Date: Thu, 13 Jan 2011 05:52:42 -0800 (PST)
Local: Thurs, Jan 13 2011 8:52 am
Subject: Re: use custom IRepository interface in SharpModelBinder
I've just pushed some updates to my sample app so that the correct
session factory key is used for standard and multi tenant repositories
(by using reflection and the IMultiTenantEntity and
IMultiTenantRepository marker interfaces).

Also, I've reorganised the code slightly which would make it easier to
add to contrib if desired (just add everything in the
SharpArchitecture.MultiTenant.Framework project). The changes to the
main SA in my pull request (https://github.com/sharparchitecture/Sharp-
Architecture/pull/1) would be required though.

On Jan 13, 9:46 am, Howard van Rooijen <howard.vanrooi...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alec Whittington  
View profile  
 More options Jan 13 2011, 11:53 am
From: Alec Whittington <alec.whitting...@gmail.com>
Date: Thu, 13 Jan 2011 09:53:34 -0700
Local: Thurs, Jan 13 2011 11:53 am
Subject: Re: use custom IRepository interface in SharpModelBinder

I think this would be a most welcome addition to the S# code base. I agree
with Howard that some of it can go into the core bits.

Great job Chris, thanks for sharing.

Cheers,
Alec Whittington
twitter: http://twitter.com/alecwhittington
<http://twitter.com/alecwhittington>blog: http://blog.sharparchitecture.net
Become a fan of S#arp Architecture on
Facebook<http://www.facebook.com/pages/Sarp-Architecture/117591724971997>

On Thu, Jan 13, 2011 at 6:52 AM, Chris Richards <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Richards  
View profile  
 More options Jan 14 2011, 7:08 am
From: Chris Richards <chris.richa...@yellowfeather.co.uk>
Date: Fri, 14 Jan 2011 04:08:52 -0800 (PST)
Local: Fri, Jan 14 2011 7:08 am
Subject: Re: use custom IRepository interface in SharpModelBinder
What's the best way of proceeding?

My existing pull request is against SA 1.9, do you want me to merge my
changes into 2.0 and send another pull request?

On Jan 13, 4:53 pm, Alec Whittington <alec.whitting...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alec Whittington  
View profile  
 More options Jan 14 2011, 10:08 am
From: Alec Whittington <alec.whitting...@gmail.com>
Date: Fri, 14 Jan 2011 08:08:06 -0700
Local: Fri, Jan 14 2011 10:08 am
Subject: Re: use custom IRepository interface in SharpModelBinder

Chris,
     the team is meeting on Sunday, we will discuss then the best way for us
to adapt this. I think our current plan is to take part of it into S# and
the other part into contrib. We'll let you know shortly.

Cheers,
Alec Whittington
twitter: http://twitter.com/alecwhittington
<http://twitter.com/alecwhittington>blog: http://blog.sharparchitecture.net
Become a fan of S#arp Architecture on
Facebook<http://www.facebook.com/pages/Sarp-Architecture/117591724971997>

On Fri, Jan 14, 2011 at 5:08 AM, Chris Richards <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »