Skip to content

Instantly share code, notes, and snippets.

@jayhjkwon
Created November 1, 2011 08:44
Show Gist options
  • Save jayhjkwon/1330167 to your computer and use it in GitHub Desktop.
Save jayhjkwon/1330167 to your computer and use it in GitHub Desktop.
CastleActiveRecordSample
class Program
{
static void Main(string[] args)
{
ActiveRecordStarter.ResetInitializationFlag();
IConfigurationSource source = new XmlConfigurationSource("appconfig.xml");
ActiveRecordStarter.Initialize(Assembly.GetAssembly(typeof(CastleActiveRecordSample.Person)), source);
ActiveRecordStarter.DropSchema();
ActiveRecordStarter.CreateSchema();
Person user1 = new Person();
user1.UserName = "kwon";
user1.Password = "hj";
user1.Create();
Person user2 = new Person();
user2.UserName = "Lee";
user2.Password = "sj";
user2.Create();
var users = Person.FindAll();
foreach (var item in users)
{
Console.WriteLine("id:{0}, name:{1}, password:{2}", item.Id, item.UserName, item.Password);
}
Console.Read();
}
}
[ActiveRecord]
public class Person : ActiveRecordBase<Person>
{
[PrimaryKey]
public int Id { get; set; }
[Property]
public string UserName { get; set; }
[Property]
public string Password { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment