It depends. For some dictionaries I'm just using them to show a user-
friendly name for a const (by joining status.name to the entity). This
is especially important on lists where I can get this information from
the database, without post-processing the data in code to add user
friendly names for consts (and order by user friendly names). In other
cases I'm allowing users to add their own values and keeping them in a
table + CRUD GUI is the easiest option. And some consts are used in
application logic in C# code - like in the example above. In all of
these cases I'm using small  tables to store these dictionaries, this
is because I prefer using one method consistently to having several
variants used in different situations. Ah, and it makes the database
more self-documenting and easy to understand - you know what all these
constants mean by looking into the dictionary table.
R
On 14 Gru, 13:40, Fabio Maulo <[email protected]> wrote:
> why you should use a table to represent constant ?
> have you some "if" on the status ? (as : if( w.Status ==
> WorkFkowStatus.Executing)...)
>
> 2009/12/13 rg <[email protected]>
>
>
>
>
>
> > Hi, I'm frequently using some short dictionary tables containing id/
> > name columns, for example to represent possible statuses of a simple
> > workflow. Such table contains few values, like:
>
> > 1, Creating
> > 2, Accepting
> > 3, Executing
> > 4, Finished
> > 5, Cancelled
>
> > and is referred by an entity representing some business object -  so
> > by joining it I can display current status of the object. My question
> > is, how to represent such constant references in C# code, so I could
> > write something like:
>
> > r = new SomeBusinessCase()
> > r.CreatedDate = DateTime.Now;
> > r.Status = WorkflowStatus.Accepting; //this should be resolved as
> > Session.Load<WorkflowStatus>(2);
>
> > As you see, having aliases for constant key references would help keep
> > the code clean. If such 'consts' were understood by NHibernate, this
> > could also be used in HQL - like "from SomeBusinessCase where Status
> > == WorkflowStatus.Executing". Is there something like that in NH, or
> > what is the best way to achieve something similar?
>
> > Best regards
> > RG
>
> > --
>
> > 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]<nhusers%[email protected] 
> > >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> 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