nhibernate

NHibernate explicit fluent column mapping

我们两清 提交于 2020-01-23 13:18:25
问题 I have a set of fluent object mappings that looks like this: public class UserMap : ClassMap<User> { public UserMap() { Map(x => x.Id); Map(x => x.Status); } } public class SpecialUserMap : SubClassMap<SpecialUser> { public SpecialUserMap() { Map(x => x.Property); } } public class DirectoryMap : ClassMap<Directory> { public DirectoryMap { Map(x => x.Id); HasMany(x => x.SpecialUsers).Where("Status = 0"); } } User is a join table, which SpecialUser joins against to get things like status.

NHibernate explicit fluent column mapping

六眼飞鱼酱① 提交于 2020-01-23 13:18:09
问题 I have a set of fluent object mappings that looks like this: public class UserMap : ClassMap<User> { public UserMap() { Map(x => x.Id); Map(x => x.Status); } } public class SpecialUserMap : SubClassMap<SpecialUser> { public SpecialUserMap() { Map(x => x.Property); } } public class DirectoryMap : ClassMap<Directory> { public DirectoryMap { Map(x => x.Id); HasMany(x => x.SpecialUsers).Where("Status = 0"); } } User is a join table, which SpecialUser joins against to get things like status.

Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties

时光怂恿深爱的人放手 提交于 2020-01-23 03:05:19
问题 I'm working on building a custom module in Orchard CMS, and I have the following Controller Action: public ActionResult Inventory() { var models = _repository.Get<MyModel>(); return View(new MyViewModel() { MyModels = models.ToList() }); } Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be. The exception is method get_Id should be 'public/protected virtual' or 'protected

Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties

[亡魂溺海] 提交于 2020-01-23 03:05:01
问题 I'm working on building a custom module in Orchard CMS, and I have the following Controller Action: public ActionResult Inventory() { var models = _repository.Get<MyModel>(); return View(new MyViewModel() { MyModels = models.ToList() }); } Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be. The exception is method get_Id should be 'public/protected virtual' or 'protected

Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties

旧巷老猫 提交于 2020-01-23 03:04:26
问题 I'm working on building a custom module in Orchard CMS, and I have the following Controller Action: public ActionResult Inventory() { var models = _repository.Get<MyModel>(); return View(new MyViewModel() { MyModels = models.ToList() }); } Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be. The exception is method get_Id should be 'public/protected virtual' or 'protected

Lazy loading for NHibernate with Ignore.NotFound

蹲街弑〆低调 提交于 2020-01-22 19:54:39
问题 I have a mapping like the bellow for a Candidate object: References(x => x.Country).Column("CountryId").NotFound().Ignore() the problem here is, if I select * Candidates I get a extra select for each of them, not a good thing, so I pull out the NotFound().Ignore() bit but now the following code fails with ObjectNotFoundException exception: if (entity.Country != null) { bos.CountryName = entity.Country.Name; } Is there a way to force Hhibernate do the select when I compare County != null ?

What are all the NHibernate HiLo generator params?

谁说胖子不能爱 提交于 2020-01-22 19:04:22
问题 I've seen some docs by Fabio Maulo that shows the following params: <id name="Id" type="Int64" column="cat_id"> <generator class="hilo"> <param name="table">hi_value</param> <param name="column">next_value</param> <param name="max_lo">100</param> </generator> </id> However, on this question the poster uses a <param name="schema">... I'd like to be able to specify schema for the HiLo generator. Is there definitive documentation for all generator parameters? I've tried googling it without

How to configure NHibernate to use connection string from <connectionStrings> configuration section

[亡魂溺海] 提交于 2020-01-22 18:51:13
问题 does anybody know how to configure NHibernate properties file to use a connection string already specified in configuration element? 回答1: I found it on google.com: <connectionStrings> <add name="connection_string_name" connectionString="[connection string]"/> </connectionStrings> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> ... <property name="connection.connection_string_name">connection_string_name</property> ... </session-factory> </hibernate

IIS7 + NHibernate: Illegal operation attempted on a registry key that has been marked for deletion

我与影子孤独终老i 提交于 2020-01-22 18:43:25
问题 We have an asp.net MVC app using Fluent Nhibernate running on top of IIS7 & Windows Sever 2008. Frequently (although so far we have yet to consistently reproduce it) after a build we get a yellow screen of death with this exception: [COMException (0x800703fa): Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA)] System.Reflection.Assembly._nDefineDynamicModule(Assembly containingAssembly, Boolean emitSymbolInfo, String filename

NHibernate many-to-many assocations making both ends as a parent by using a relationship entity in the Domain Model

泄露秘密 提交于 2020-01-22 16:56:09
问题 Entities: Team <-> TeamEmployee <-> Employee Requirements: A Team and an Employee can exist without its counterpart. In the Team-TeamEmployee relation the Team is responsible (parent) [using later a TeamRepository]. In the Employee-TeamEmployee relation the Employee is responsible (parent) [using later an EmployeeRepository]. Duplicates are not allowed. Deleting a Team deletes all Employees in the Team, if the Employee is not in another Team. Deleting an Employee deletes only a Team, if the