Tôi vừa yêu NHibernate và giao diện thông thạo. Sau này cho phép ánh xạ rất đẹp với hỗ trợ tái cấu trúc (không cần nhiều hơn cho các tệp xml).Kết hợp ánh xạ XML và Linh hoạt cho NHibnernate
Nhưng không ai là hoàn hảo, vì vậy tôi thiếu bản đồ nhiều đối tượng thành thạo. Có ai biết nếu nó đã có? Nếu vậy, một dòng mã đơn giản sẽ rất tuyệt.
Nhưng để dính vào tiêu đề của câu hỏi, có cách nào kết hợp ánh xạ NHibernate thông thường và thông thường không.
Hiện tại tôi sử dụng các dòng sau cho thiết lập thử nghiệm của tôi VỚI thông thạo, và khối mã thứ hai cho thử nghiệm của tôi KHÔNG thông thạo (với ánh xạ XML). Làm thế nào tôi có thể nói thông thạo sử dụng thông thạo NẾU CÓ và XML khác ...
var cfg = new Configuration();
cfg.AddProperties(MsSqlConfiguration.MsSql2005.ConnectionString.Is(_testConnectionstring).ToProperties());
cfg.AddMappingsFromAssembly(typeof(CatMap).Assembly);
new SchemaExport(cfg).Create(true, true);
var persistenceModel = new PersistenceModel();
persistenceModel.addMappingsFromAssembly(typeof(CatMap).Assembly);
IDictionary<string, string> properties = MsSqlConfiguration.MsSql2005.UseOuterJoin().ShowSql().ConnectionString.Is(_testConnectionstring).ToProperties();
properties.Add("command_timeout", "340");
session = new SessionSource(properties, persistenceModel).CreateSession();
Nếu không thạo ...
config = new Configuration();
IDictionary props = new Hashtable();
props["connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
props["dialect"] = "NHibernate.Dialect.MsSql2005Dialect";
props["connection.driver_class"] = "NHibernate.Driver.SqlClientDriver";
props["connection.connection_string"] = "Server=localhost;initial catalog=Debug;Integrated Security=SSPI";
props["show_sql"] = "true";
foreach (DictionaryEntry de in props)
{
config.SetProperty(de.Key.ToString(), de.Value.ToString());
}
config.AddAssembly(typeof(CatMap).Assembly);
SchemaExport se = new SchemaExport(config);
se.Create(true, true);
factory = config.BuildSessionFactory();
session = factory.OpenSession();
Vậy đó ... Chris
PS: Tôi thực sự giống như trang web này, GUI là hoàn hảo và chất lượng của tất cả các bài viết là không thể tin được. Tôi nghĩ rằng nó sẽ được :-) khổng lồ Phải đăng ký ...