Guest User

Untitled

a guest
Aug 19th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. ActiveRecordStarter.ResetInitializationFlag();
  6.  
  7. IConfigurationSource source = new XmlConfigurationSource("appconfig.xml");
  8. ActiveRecordStarter.Initialize(Assembly.GetAssembly(typeof(CastleActiveRecordSample.Person)), source);
  9.  
  10. ActiveRecordStarter.DropSchema();
  11. ActiveRecordStarter.CreateSchema();
  12.  
  13. Person user1 = new Person();
  14. user1.UserName = "kwon";
  15. user1.Password = "hj";
  16. user1.Create();
  17.  
  18. Person user2 = new Person();
  19. user2.UserName = "Lee";
  20. user2.Password = "sj";
  21. user2.Create();
  22.  
  23. var users = Person.FindAll();
  24.  
  25. foreach (var item in users)
  26. {
  27. Console.WriteLine("id:{0}, name:{1}, password:{2}", item.Id, item.UserName, item.Password);
  28. }
  29.  
  30. Console.Read();
  31. }
  32. }
  33.  
  34. [ActiveRecord]
  35. public class Person : ActiveRecordBase<Person>
  36. {
  37. [PrimaryKey]
  38. public int Id { get; set; }
  39.  
  40. [Property]
  41. public string UserName { get; set; }
  42.  
  43. [Property]
  44. public string Password { get; set; }
  45. }
Add Comment
Please, Sign In to add comment