Skip to content

Instantly share code, notes, and snippets.

@jmkelly
Forked from luisrudge/Brand.cs
Last active December 15, 2015 12:19
Show Gist options
  • Save jmkelly/5259676 to your computer and use it in GitHub Desktop.
Save jmkelly/5259676 to your computer and use it in GitHub Desktop.
public class Brand : IBrand
{
public int Id { get; set; }
public string Name { get; set; }
public int? ParentBrandId { get; set; }
}
CREATE TABLE [dbo].[tbBrand](
[idBrand] [smallint] IDENTITY(1,1) NOT NULL,
[braName] [varchar](100) NOT NULL,
[idParentBrand] [smallint] NULL,
CONSTRAINT [PK__tbBrand__E353A48E005FFE8A] PRIMARY KEY CLUSTERED
(
[idBrand] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].[tbBrand] WITH NOCHECK ADD CONSTRAINT [FK_tbBrand_tbBrand] FOREIGN KEY([idParentBrand])
REFERENCES [dbo].[tbBrand] ([idBrand])
using PetaPoco;
[TableName("dbo.tbBrand")]
[PrimaryKey("idBrand")]
public class Brand : IBrand
{
[Column("idBrand")]
public int Id { get; private set; }
[Column("braName")]
public string Name { get; set; }
[Column("idParentBrand")]
public int? ParentBrandId { get; set; }
}
public class BrandRepository : PetaPocoRepositoryBase, IBrandRepository
{
public IBrand GetById(string campaignId, int id)
{
//Db = Petapoco.Database
return (IBrand)Db.FirstOrDefault<BrandPetaPoco>( id );
}
}
public interface IBrand
{
int Id { get; set; }
string Name { get; set; }
int? ParentBrandId { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment