Cheers, I had tried this, but the resulting SQL was faulty.

I had used a formula similar to this:
m.Map(x => x.Country).Formula("(select CountryName from CountrySetting
where Id = 1)");
m.Map(x => x.Country).Formula("(select cs.CountryName from
CountrySetting cs where cs.Id = 1)");

In both cases, the generate SQL contained my column names prefixed
with the source table alias.
(select Customer0_1_.CountryName from CountrySetting where
Customer0_1_.Id = 1)

After reading your answer, I revisited the solution by not using a
table alias, but the actual table name.
m.Map(x => x.Country).Formula("(select CountrySetting.CountryName from
CountrySetting where CountrySetting.Id = 1)");

It worked like a charm.

Regards

Joe

On Feb 11, 7:24 am, John Davidson <[email protected]> wrote:
> Try using a formula to add the property to your object
>
> John Davidson
>
> On Fri, Feb 11, 2011 at 1:40 AM, Wildjoe182 <[email protected]>wrote:
>
> > Ok, before I start, I feel the need to admit that I'm not proud of
> > what I'm trying to achieve, but basically, I'm stuck with a very bad
> > legacy database and I'm trying to make the best of it for the
> > developers.
>
> > I would like to solve the following:
> > I have a Customer entity, which is mapped. [source: Customer table;
> > basic customer fields]
> > The customer, has an Address component. [source: Customer table;
> > address related fields]
> > I would like to include the country in the Address.
>
> > Here is the catch; the country is not a column on the Customer table,
> > it is a system wide setting. It would be located in a settings table.
>
> > For Example:
> > Table: CountrySetting
> > Id: 1
> > CountryName: US
>
> > When I load my Address component as part of my customer, I would like
> > to include the "CountryName" as part of the Address. Mapped to a
> > Property named "Country" on the Address object.
>
> > For me, it is acceptable to assume that I know the Id of the
> > CountrySetting row.
>
> > I'm Using NH3 with Fluent NH.
>
> > I know this sounds a bit crazy, but I don't want to have to go and
> > read the settings table every time I want to print an address.
>
> > Any help or alternate solutions are welcome.
>
> > Best Regards
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to