Skip to content

Instantly share code, notes, and snippets.

@mythz

mythz/main.cs

Created Aug 6, 2019
Embed
What would you like to do?
Create Project Table Test
using System;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection
OrmLiteUtils.PrintSql();
public abstract class BaseAuditFields
{
public DateTime CreatedDate { get; set; }
public string CreatedBy { get; set; }
public DateTime ModifiedDate { get; set; }
public String ModifiedBy { get; set; }
protected BaseAuditFields()
{
CreatedBy = "sys";
CreatedDate = DateTime.Now;
ModifiedBy = "sys";
ModifiedDate = DateTime.Now;
}
}
[Alias("Projects")]
public class Project : BaseAuditFields
{
[PrimaryKey, AutoId]
public Guid ProjectId { get; set; }
[Required, StringLength(16), Unique]
public string ProjectCode { get; set; }
[Required, StringLength(100)]
public string ProjectName { get; set; }
[Ignore]
public string TranslatedInNos { get; set; }
[Ignore]
public int TotalWordCount { get; set; }
}
db.CreateTable<Project>();
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="5.5.0" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.5.0" targetFramework="net45" />
<package id="ServiceStack.Common" version="5.5.0" targetFramework="net45" />
<package id="ServiceStack.OrmLite" version="5.5.0" targetFramework="net45" />
<package id="ServiceStack.OrmLite.Sqlite.Windows" version="5.5.0" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment