Last active
November 2, 2015 16:59
-
-
Save bartread/6afdcafbec3c5f567ba2 to your computer and use it in GitHub Desktop.
POCO entity definitions for simplified user schema
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 System; | |
using System.Collections.Generic; | |
namespace SimpleSavePocoEntities | |
{ | |
public class UserDao | |
{ | |
public int UserKey { get; set; } | |
public Guid UserGuid { get; set; } | |
public int EmployeeId { get; set; } | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public string Username { get; set; } | |
// More public properties here - we're going to ignore them because they're mostly not interesting | |
// Here are the interesting ones | |
public IList<DepartmentDao> Departments {get; set;} | |
public IList<LoginDao> Logins {get; set;} | |
} | |
public class DepartmentDao | |
{ | |
public int DepartmentKey { get; set; } | |
public string Name { get; set; } | |
public string Description { get; set; } | |
public bool IsExternal { get; set; } | |
public bool IsSalesChannel { get; set; } | |
} | |
public class LoginDao | |
{ | |
public int LoginKey { get; set; } | |
public int UserKey { get; set; } | |
// This property represents a foreign key relationship against a table that, in this | |
// scenario, we don't care about. | |
public int AllowedIpKey { get; set; } | |
// N.B. In the database this column is actually an INT. Dapper supports | |
// automatic mapping between C# enums and numeric columns in the database. | |
// The C# enum must extend the simple type most closely corresponding to | |
// the database numeric type. E.g., if your database column is an INT your | |
// C# enum should extend Int32 (the default). | |
// | |
// If you need to map to a string in the database you must use a CustomPropertyTypeMap. | |
// See http://stackoverflow.com/questions/8902674/manually-map-column-names-with-class-properties/12615036#12615036 | |
// for more information. | |
// | |
// (Another possible solution is to use a shadow property to save and load the string value. | |
// E.g., http://stackoverflow.com/questions/6192512/store-enum-as-string-in-database) | |
public UserLoginResultEnum LoginResultKey { get; set; } | |
public string IpAddress { get; set; } | |
public DateTimeOffset Timestamp { get; set; } | |
// Ignoring UpdateDate and UpdateUserKey because these are just audit columns | |
} | |
public enum UserLoginResultEnum : int | |
{ | |
Success = 0, | |
Failed = 1, | |
PasswordFailed = 2, | |
PasswordLocked = 3, | |
AdministrativeLock = 4, | |
RemoteAccessDenied = 5, | |
RemoteAccessValidationPrompt = 6, | |
AccountUnlocked = 7, | |
UserIsImpersonated = 8, | |
UserPasswordChanged = 9, | |
PasswordHasBeenReset = 10 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment