Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Created July 17, 2014 12:24
Show Gist options
  • Save hagbarddenstore/61aa41e8416b5d216bc5 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/61aa41e8416b5d216bc5 to your computer and use it in GitHub Desktop.
class Page
{
public Guid Id { get; set; }
public DateTime CreatedOn { get; set; }
public Dictionary<string, string> Title { get; set; }
public Dictionary<string, string> Content { get; set; }
}
class Post
{
public Guid Id { get; set; }
public DateTime CreatedOn { get; set; }
public Dictionary<string, string> Title { get; set; }
public Dictionary<string, string> Content { get; set; }
}
-- Select a single page
SELECT *
FROM [Pages] AS p
LEFT JOIN [Resources] AS r ON r.[EntityId] = p.[Id]
WHERE p.[Id] = @PageId;
-- Select a single post
SELECT *
FROM [Posts] AS p
LEFT JOIN [Resources] AS r ON r.[EntityId] = p.[Id]
WHERE p.[Id] = @PostId;
CREATE TABLE [Pages] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[CreatedOn] DATETIME NOT NULL,
PRIMARY KEY ([Id])
);
CREATE TABLE [Posts] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[CreatedOn] DATETIME NOT NULL,
PRIMARY KEY ([Id])
);
CREATE TABLE [Resources] (
[EntityId] UNIQUEIDENTIFIER NOT NULL,
[PropertyName] VARCHAR(100) NOT NULL,
[LanguageIsoCode] CHAR(7) NOT NULL,
[Value] NVARCHAR(MAX),
PRIMARY KEY ([EntityId], [PropertyName], [LanguageIsoCode])
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment