Created
November 23, 2015 22:27
-
-
Save rudism/ee7934166ba5eff1c4b2 to your computer and use it in GitHub Desktop.
This file contains 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
namespace selectenum | |
{ | |
using ServiceStack.DataAnnotations; | |
using ServiceStack.OrmLite; | |
using ServiceStack.Text; | |
enum MyEnum | |
{ | |
FirstValue, | |
SecondValue | |
} | |
class DataObject | |
{ | |
[AutoIncrement] | |
public int Id { get; set; } | |
public MyEnum Value { get; set; } | |
} | |
class MainClass | |
{ | |
public static void Main (string[] args) | |
{ | |
var factory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider); | |
using(var db = factory.OpenDbConnection()) | |
{ | |
db.CreateTable<DataObject>(); | |
var obj = new DataObject { Value = MyEnum.SecondValue }; | |
db.Save(obj); | |
obj.PrintDump(); | |
var myvalue = db.Scalar<MyEnum>(db.From<DataObject>() | |
.Where(o => o.Id == obj.Id) | |
.Select(o => o.Value)); | |
myvalue.PrintDump(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment