I think this is a moderately neophyte question. I've been using NHibernate/FluentNHibernate for about 6 months or so, and I think I have a fair grasp of the basics. Now I'm pushing a little bit beyond. I'm sure this is documented, but I've spent several hours now on Google, and haven't quite figured it out.
I have simple class, call it Simple:
public class Simple
{ public string Name { get; set;}
public string Desc { get; set; }
public string Status { get; set;}
}
Status is actually constrained to be one of a small set of values: "ACTIVE", "ON-HOLD", and "CLOSED". In the DB schema, I have a simple read-only table called RetrofitStatus:
CREATE TABLE [dbo].[RetrofitStatus](
[Status] [nvarchar](10) NOT NULL,
[SortOrder] [smallint] NOT NULL,
CONSTRAINT [PK_RetrofitStatus] PRIMARY KEY CLUSTERED
(
[Status] ASC
)
And there's a Foreign-key constraint on the Simple table to make sure Status is in RetrofitStatus.
The purpose of the RetrofitStatus table is to include the SortOrder column so that I can do (in SQL)
SELECT * from Simple s join RetrofitStatus r on r.Status=s.Status ORDER BY r.SortOrder
and sort my results into a display order (e.g., all ACTIVE entries first, then ON-HOLD entries, then CLOSED entries, since I'm sorting on a logical order, not alphabetical or anything else easily recognize).
My question is, how do I model that object and relationship in FNH? I can add the SortOrder property to my Simple definition and a make a View that represents that, but what will happen when I try to insert new Simple objects into the table? Obviously, I don't want to try to insert the SortOrder property. I think I need to use the NHib element somehow, but again, I'm not clear on where that needs to go, what happens on insert, and how to do it in Fluent?
I'm going to try experimenting with trial-and-error, but I thought that maybe somebody who knows what they're doing (which I don't) can point me in the right direction and save me some time. Thanks for your help.