fluent-nhibernate

Use of TransactionScope with read uncommitted - is with (nolock) in SQL necessary?

自作多情 提交于 2019-12-04 01:55:34
I am using FluentNHibernate, and I have a list of records, mapped to an SQL Server 2008 view. Dirty reads are OK with me, not locking the tables is a priority. The SQL Query inside the view, does not have any with (nolock), however, I am using the following approach... using (var txScope = new TransactionScope(TransactionScopeOption.Suppress, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { ... The reading of records from the view is done here, through Fluent NHibernate... } Does setting the isolation level at application layer to read

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

左心房为你撑大大i 提交于 2019-12-03 22:47:50
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 Team does not contain no more Employees. Mapping: public class TeamMap : ClassMap<Team> { public TeamMap

What are the differences between HasOne and References in nhibernate?

£可爱£侵袭症+ 提交于 2019-12-03 22:03:35
What are the differences between HasOne() and References() in nhibernate? Abel HasOne creates a one-to-one mapping between tables for you. References creates a typical relational many-to-one relationship. More defined: a one-to-one relationship means that when one record exists in one table, it must (or can) have one and at most one record in the other referenced table. Example: User table and Options table (one user has one fixed set of options) a many-to-one relationship means that when one records exists in one table, it can have many related records in another table. Example: User table

Need help with NHibernate / Fluent NHibernate mapping

a 夏天 提交于 2019-12-03 21:36:48
Let's say your have the following table structure: ============================== | Case | ============================== | Id | int | | ReferralType | varchar(10) | +---------| ReferralId | int |---------+ | ============================== | | | | | | | ====================== ====================== ====================== | SourceA | | SourceB | | SourceC | ====================== ====================== ====================== | Id | int | | Id | int | | Id | int | | Name | varchar(50) | | Name | varchar(50) | | Name | varchar(50) | ====================== ====================== ==================

FluentNHibernate - Automapping ignore property

和自甴很熟 提交于 2019-12-03 20:36:55
I have a base class that contains a property called IsDirty. This is used for the domain model and is not a column in the database table. When using automapping, fluent nhibernate tries to add this column to the table. A way to fix this is to put .ForTypesThatDeriveFrom<Address>(p => p.IgnoreProperty(x => x.IsDirty)) in the automapping setup. The problem is, all my entities will do this, is there a way to state this without have to add this line for every entity? If I put .ForTypesThatDeriveFrom<Entity>(p => p.IgnoreProperty(x => x.IsDirty)) , then I get an error trying to convert Entity to

Fluent NHibernate DuplicateMappingException with AutoMapping

风格不统一 提交于 2019-12-03 20:21:35
问题 Summary: I want to save two classes of the same name and different namespaces with the Fluent NHibernate Automapper Context I'm writing having to import a lot of different objects to database for testing. I'll eventually write mappers to a proper model. I've been using code gen and Fluent NHibernate to take these DTOs and dump them straight to db. the exception does say to (try using auto-import="false") Code public class ClassConvention : IClassConvention { public void Apply(IClassInstance

Most painless multi-tenancy implementation using ASP.NET, NHibernate / Fluent NHibernate

江枫思渺然 提交于 2019-12-03 20:14:45
I'm trying to implement multi-tenancy in an ASP.NET MVC application I have, that uses NHibernate. Though I have control over the database for multi-tenancy. I'm trying to figure out the best way to filter our database queries using NHibernate. I would like to know if there is a painless way where I can append a condition (something like WHERE InstanceID = 1 ) to every CRUD query to the DB using NHibernate. I looked at global filters. But I wasn't sure if I'm using it the right way. I tried something like this. NHibernateSession.GetDefaultSessionFactory().GetCurrentSession() .EnableFilter(

NHibernate / Fluent NHibernate Dynamic Column Mapping

喜欢而已 提交于 2019-12-03 20:07:50
I have a table that, some of its columns are unknown at compile time. Such columns could either be of an integer value, or some Enum value. There is a table that holds all the names of such dynamic columns and also holds the column's type. This "metatable" has the following columns: DynamicColumnId (Pk) Name TypeId (Integer / Enum, as Fk from a separate table) Integer columns have the Name from this table, whereas Enum columns are Fk columns from a table that has that Name , with some modification (e.g. a "DynamicTable" prefix). The only solution I could think of for this situation is using

How does one make NHibernate stop using nvarchar(4000) for insert parameter strings?

六月ゝ 毕业季﹏ 提交于 2019-12-03 17:15:24
问题 I need to optimize a query that is being produced by a save (insert query) on a domain entity. I've configured NHibernate using Fluent NHibernate. Here's the query generated by NHibernate during the insertion of a user's response to a poll: exec sp_executesql N'INSERT INTO dbo.Response (ModifiedDate, IpAddress, CountryCode, IsRemoteAddr, PollId) VALUES (@p0, @p1, @p2, @p3, @p4); select SCOPE_IDENTITY()',N'@p0 datetime,@p1 nvarchar(4000),@p2 nvarchar(4000),@p3 bit,@p4 int', @p0='2001-07-08 03

Is NHibernate SchemaUpdate safe in production code?

陌路散爱 提交于 2019-12-03 17:13:19
问题 For simplicity's sake. I'm using Fluent NHibernate's Automapping combined with NHibernate's SchemaUpdate during runtime. On each run Automapper creates mappings for all entity classes and SchemaUpdate applies the schema to the existing database. I was pleasantly surprised that it works correctly against an empty database as well. It's worked fine so far in a development environment and has allowed me to respond to bugs rather quickly. My question is whether it is reliable enough to leave in