Created
March 2, 2012 18:34
-
-
Save ioleksiy/1960254 to your computer and use it in GitHub Desktop.
AcroDB. The beginning
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
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(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The article http://www.oleksiy.pro/2010/03/20/acrodb-the-beginning/