Skip to content

Instantly share code, notes, and snippets.

@ioleksiy
Created March 2, 2012 18:34
Show Gist options
  • Save ioleksiy/1960254 to your computer and use it in GitHub Desktop.
Save ioleksiy/1960254 to your computer and use it in GitHub Desktop.
AcroDB. The beginning
using System;
using System.Reflection;
using AcroDB;
using AcroDB.Attributes;
using AcroDB.MongoDb;
using AcroDB.MsSql;
namespace AcroDBTest
{
[AcroDbEntity]
public interface IUser
{
Guid ID { get; set; }
string Name { get; set; }
}
class Program
{
static string[] SettingsCallBack(string name)
{
if (name == "MsSql")
return new[] { @"server=localhost;Database=acrodbtest;Trusted_Connection=True;" };
return new string[0];
}
static void Main()
{
DataContextFactory.SettingsCallback = SettingsCallBack;
DataContextFactory.Instance.ScanAssembly(typeof(MsSqlDataContext).Assembly);
AcroDataContext.DefaultDataContext = DataContextFactory.Instance.Get("MsSql");
AcroDataContext.ScanAssemblyForEntities(Assembly.GetExecutingAssembly());
using (var manager = AcroDataContext.Go)
{
var usr = manager.Provide<IUser>().Create();
usr.Name = "Some user name";
manager.Provide<IUser>().Save(usr);
manager.SubmitChanges();
}
}
}
}
@ioleksiy
Copy link
Author

ioleksiy commented Mar 3, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment