Please forgive the clumsy question (if you can figure out a better way to word the question feel free to edit away).
I have two classes SupportTicketCategory and SupportTicket (respectively):
public class SupportTicketCategory
{
public SupportTicketCategory()
{ }
private int _supportTicketCategoryID;
public virtual int SupportTicketCategoryID
{
get { return _supportTicketCategoryID; }
set
{
_supportTicketCategoryID = value;
}
}
private string _supportTicketCategoryName;
public virtual string SupportTicketCategoryName
{
get { return _supportTicketCategoryName; }
set
{
_supportTicketCategoryName = value;
}
}
}
and
public SupportTicket()
{ }
private int _supportTicketID;
public virtual int SupportTicketID
{
get { return _supportTicketID; }
set
{
_supportTicketID = value;
}
}
private SupportTicketCategory _supportTicketCategory;
public virtual SupportTicketCategory SupportTicketCategory { get; set; }
My table structure is as follows:
CREATE TABLE [dbo].[supporttickets](
[supportticketid] [int] IDENTITY(1,1) NOT NULL,
[supportticketcategoryid] [int] NOT NULL,
CONSTRAINT [PK_supporttickets] PRIMARY KEY CLUSTERED
(
[supportticketid] ASC
)
) ON [PRIMARY]
ALTER TABLE [dbo].[supporttickets]
WITH CHECK ADD CONSTRAINT
[FK_supporttickets_supportticketcategories]
FOREIGN KEY([supportticketcategoryid])
REFERENCES [dbo].[supportticketcategories] ([supportticketcategoryid])
ALTER TABLE [dbo].[supporttickets] CHECK CONSTRAINT [FK_supporttickets_supportticketcategories]
CREATE TABLE [dbo].[supportticketcategories](
[supportticketcategoryid] [int] IDENTITY(1,1) NOT NULL,
[supportticketcategoryname] [varchar](50) NOT NULL,
CONSTRAINT [PK_supportticketcategories] PRIMARY KEY CLUSTERED
(
[supportticketcategoryid] ASC
)
) ON [PRIMARY]
So basically, I want to map a SupportTicketCategory onto the SupportTicket like it is in my class, however I cannot figure out what is the proper mapping type and cannot find an example of this on the interwebs.
Update: I changed the SupportTicketCategory property to old school getters and setters and it worked...syntax sugar for loss.