fluent-nhibernate

How do add NOLOCK with nHibernate?

夙愿已清 提交于 2019-12-17 06:36:43
问题 How do you add NOLOCK when using nhibernate? (criteria query) 回答1: SetLockMode(LockMode.None) or connection.isolation ReadUncomitted does NOT append a NOLOCK to your queries. Ayende goes into the correct answer on his blog: If you're using <sql-query> you can do the following: <sql-query name="PeopleByName"> <return alias="person" class="Person"/> SELECT {person.*} FROM People {person} WITH(nolock) WHERE {person}.Name LIKE :name </sql-query> Note the WTIH(nolock) appended to the FROM clause.

NHibernate Expression.Like Criteria on Two Fields

≡放荡痞女 提交于 2019-12-14 04:25:16
问题 I have an Nhibernate object that has the properties Firstname and Surname, and I'd like to be able to query on both fields (Firstname + " " + Surname); e.g. If the search term is "John Doe", this will be matched when John and Doe are in seperate fields. How can I achieve that? Thanks! 回答1: So I ended up going with: .Add(Restrictions.Like(Projections.SqlFunction("concat", NHibernateUtil.String, Projections.Property("Firstname"), Projections.Constant(" "), Projections.Property("Surname")),

fluent nhibernate configuration not working

我怕爱的太早我们不能终老 提交于 2019-12-14 04:10:01
问题 Solved: ClassMap when configuration in code, ClassMapping when configuration in config file, but mapping in code. When trying to save an object of type Object1 to my database I get the error: No persister for: Object1. Class definition: public class Object1 { public virtual Guid Id { get; protected set; } public virtual DateTime Created { get; protected set; } public virtual DateTime LastModified { get; protected set; } public virtual Other Reference { get; set; } } mapping: public class

Fluent NHibernate Adding and Updating problem : References

☆樱花仙子☆ 提交于 2019-12-14 04:07:06
问题 Im fairly n00bish when it comes to fluent nhibernate but i have an unexpected error in one of my repositories. I have a datatype CostCode public class CostCode { public virtual int Id { get; set; } public virtual String CostCodeCode { get; set; } public virtual Company Company { get; set; } public virtual DateTime CreatedDate { get; set; } public virtual String CreatedBy { get; set; } public virtual DateTime ModifiedDate { get; set; } public virtual String ModifiedBy { get; set; } } and here

Why do I get a System.OutOfMemoryException using NHibernate?

落花浮王杯 提交于 2019-12-14 03:59:20
问题 Below are the details of the error: Scenario: I'm iteration through a collection which contains a field with 'byte[]' as datatype. While iterating it is allocating byte array in lakhs. I guess this may be the suspect. Error details: Exception of type 'System.OutOfMemoryException' was thrown. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Fluent NHibernate Collection Table-Per-Subclass

会有一股神秘感。 提交于 2019-12-14 03:48:02
问题 I am having trouble with inheritance in Fluent NHibernate. I have managed to get Table-Per-Subclass working before but I can't get a collection of the baseclass to work. It is looking for a table for the base class which I don't have. Here's my schema: User(Id, Name, Email) User_Account_Password(Id, UserId, PasswordHash, Salt) User_Account_Facebook(Id, UserId, FacebookId) Here's my object model: public class User { public virtual int Id { get; set; } public virtual string Name { get; set; }

Fluent NHibernate List of objects exception

ⅰ亾dé卋堺 提交于 2019-12-14 03:19:02
问题 I have a DAL using Fluent NHibernate for mapping a query (stored in db as strings) and their parameters (stored in a separate table). When I try to use this list of parameters in the service layer, I run into problems. List<QueryParameter> lqp = (List<QueryParameter>)qry.parameters; Throws Unable to cast object of type Hibernate.Collection.Generic.PersistentGenericBag 1[nha.cs.utility.mole.QueryParameter]' to type 'System.Collections.Generic.List 1 [nha.cs.utility.mole.QueryParameter]'. List

FluentNHibernate - ReferencesAny(), How to use QueryOver with filter?

我的梦境 提交于 2019-12-14 03:09:05
问题 I have an UserAccount class, which may belong to an Employee or a Client I don't know how to QueryOver a object OwnerRefObject field, with a filter. For Example: public class UserAccount { public virtual int Id {get;set;} public virtual string UserName {get;set;} public virtual string Password {get;set;} public virtual object OwnerRefObject {get;set;} } public class UserMap:ClassMap<User> { public UserMap() { Id(x => x.Id).GeneratedBy.Indentity(); Map(x => x.UserName); Map(x => x.Password);

NHibernate and Transactions - “Transaction not connected, or was disconnected”

强颜欢笑 提交于 2019-12-14 02:34:38
问题 The following is a representative snippet of my code where an unexpected, at least on my part, exception is being thrown at the transaction.Rollback() statement. The exception is of type NHibernate.TransactionException and the message is "Transaction not connected, or was disconnected." And the stack trace looks like this: NHibernate.Transaction.AdoTransaction.CheckNotZombied() at NHibernate.Transaction.AdoTransaction.Rollback() . IEmployeeService employeeService = new EmployeeService(session

Why is Fluent NHibernate with LINQ returning an empty list (with Oracle database)?

只愿长相守 提交于 2019-12-14 02:28:20
问题 I'm using Fluent NHibernate (the NH3 build - #694) and LINQ to connect to an Oracle 11 database. However, I don't seem to be able to get any data from the database. The connection seems to be working, as, if I change my login info, it throws an error. I'm using the following code: // Setup. OracleClientConfiguration oracleClientConfiguration = OracleClientConfiguration.Oracle10 .ShowSql() .ConnectionString(connectionString); _sessionFactory = Fluently.Configure() .Database