Created
March 24, 2014 20:50
-
-
Save cerkit/9748886 to your computer and use it in GitHub Desktop.
This is the generic base repository class that handles data store operations with the Entity classes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Newtonsoft.Json; | |
using RecordKeeper.Portable.Models; | |
using System.IO; | |
using System.Security.Principal; | |
using System.Threading; | |
namespace RecordKeeper.Data.Repositories | |
{ | |
public abstract class RepositoryBase<TEntity> where TEntity : EntityBase | |
{ | |
protected readonly IIdentity Identity; | |
protected readonly string ConnectionString; | |
protected RepositoryBase() | |
{ | |
ConnectionString = "Your Database Connection String Here"; | |
Identity = Thread.CurrentPrincipal.Identity; | |
} | |
public static TEntity FromJson(string json) | |
{ | |
TEntity entity; | |
JsonSerializer s = new JsonSerializer(); | |
StringReader sr = new StringReader(json); | |
JsonTextReader r = new JsonTextReader(sr); | |
entity = s.Deserialize<TEntity>(r); | |
return entity; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment