castle ActiveRecord 初始化

1.初始化单个实体类

ActiveRecordStarter.Initialize( source, typeof(User) );

  

2.初始化多个实体类

   

1.
ActiveRecordStarter.Initialize( source, typeof(Order),typeof(Product));
2
IConfigurationSource source = System.Configuration.ConfigurationManager.GetSection("activerecord") as     IConfigurationSource; 

Type[] paramTypes
= new Type[3];
paramTypes[
0] = typeof(User1);
paramTypes[
1] = typeof(Post);
paramTypes[
2] = typeof(Blog);
ActiveRecordStarter.Initialize(source, paramTypes);
3
Assembly assembly = Assembly.Load("ARTest"); 

ActiveRecordStarter.Initialize(assembly, source);

 

 

  4.

// 获取数据库连接配置
XmlConfigurationSource source = new XmlConfigurationSource(@"Config\ActiveRecord.xml");

// 载入程序集中所有 ActiveRecord 类。
ActiveRecordStarter.Initialize(Assembly.GetExecutingAssembly(), source);

// 这样可以一次初始化所有的程序集里面的类。

  

你可能感兴趣的:(ActiveRecord)