Created
November 1, 2011 08:44
-
-
Save jayhjkwon/1330167 to your computer and use it in GitHub Desktop.
CastleActiveRecordSample
This file contains hidden or 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
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