Yeahh. I agree. Thanks for the good info.

But I am not sure I really want to keep all my lookup values in the app.
The DBA will tell me one day "I have inserted a country (or whatever)
but the applicaton doesn't pick it. Go and fix.".
And I will have to... get the project... add lookup...
[(UNIT/)TEST...] recompile... deploy...

If there will be no table that stores all the lookup values the DBA
also complains :)

I currently have no good arguments to defend these 2 scenariouses (Yes
it is very likely that in 4 years nothing will be changed, but DBA
always wants to know he CAN do it).

Maybe some kind of NotVeryWellKnownValues approach...
mix static values in code and values from DB.

But honestly saying I have no good idea how it can be implemented.

The main problems is that object from DB is NOT same as static
instance of the object.
So replacing existing object from DB by its statatic instance will
cause the NH Exception, saying 2 objects with the same Id should not
exist.

Cheers,
Dmitriy.

On 03/08/2009, Fabio Maulo <[email protected]> wrote:
> For an enum with a description I prefer the Ken's solution.
> http://nhforge.org/wikis/howtonh/persisiting-described-enums.aspx
>
> <http://nhforge.org/wikis/howtonh/persisiting-described-enums.aspx>For
> something more complex I prefer my solution:
> http://fabiomaulo.blogspot.com/2009/08/from-db-to-ram-wellknowinstancetype.html
>
> <http://fabiomaulo.blogspot.com/2009/08/from-db-to-ram-wellknowinstancetype.html>
>
> public class CountryType : WellKnowInstanceType<Country>
> {
>  public CountryType() : base(new Countries(), (e, k) => e.Id == k, e =>
> e.Id) {}
> }
>
>
> 2009/8/3 Dmitiry Nagirnyak <[email protected]>
>
>> Hi,
>>
>> I'm sure it should be simple. How can I assign property (lookup value)
>> without a DB roundtrip to obtain ID of the lookup?
>>
>> // THIS IS WHAT I USED TO DO
>> address.Country = Session.Get<Country>(14);
>>
>>  // THIS IS WHAT DO NOW
>> address.Country = PredefinedCountries.Australia;
>>
>> The last approach work ONLY if the Country has not been loaded into
>> Session. NonUniqueObjectException is thrown.
>>
>> So I have to Evict the object first or just load the actual object (using
>> the approach 1).
>>
>> How can I avoid doing Evict in this case?
>>
>> And yes, I did override Equals and GetHashCode (even == operators).
>>
>> I saw custom user type approach:
>> http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/08/12/enumeration-classes.aspx
>> But it is overkill for my need.
>>
>> Cheers,
>> Dmitriy.
>>
>> >
>>
>
>
> --
> Fabio Maulo
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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