I've got an object that contains an EntitySet using a specific key that is fixed for the lifetime of the application.

I would like this to materialize in the constructor; so I'm doing this:

pendingList  = session.Query.SingleOrDefault<NotificationList>(Queue_ID);

if (pendingList == null)
    pendingList = new NotificationList(Queue_ID);

Is this the right way of doing this. The Queue_ID is a const string, and pendingList is an Entity.

asked Mar 14 '11 at 13:52

RichardHarrison's gravatar image

RichardHarrison
21447


One Answer:

Exactly.

Also, I'd recommend to mark NotificationList class with [KeyGenerator(KeyGeneratorKind.None)] attribute.

answered Mar 15 '11 at 04:05

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

edited Mar 15 '11 at 04:06

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×5
×1

Asked: Mar 14 '11 at 13:52

Seen: 3,424 times

Last updated: Mar 15 '11 at 04:06

powered by OSQA