Skip to content

Instantly share code, notes, and snippets.

@rudism
Created November 23, 2015 22:27
Show Gist options
  • Save rudism/ee7934166ba5eff1c4b2 to your computer and use it in GitHub Desktop.
Save rudism/ee7934166ba5eff1c4b2 to your computer and use it in GitHub Desktop.
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