nhibernate

NHibernate Session.Query<>, column list?

房东的猫 提交于 2019-12-25 03:52:40
问题 We have some code written which depends on working with the IQueryable instances, so I suppose we are stuck with having to use ISession.Query<>() . In one particular case I would like to only partially hydrate the DBOs and exclude certain columns from the SELECT statement which NHibernate will generate. Is it possible to achieve that while using Query<> ? Alternatively, is it possible to somehow go from ICriteria to IQueryable ? (I think for ICriteria it is possible to achieve what I need by

creating class for stored procedure, returning data from multiple tables

喜夏-厌秋 提交于 2019-12-25 03:49:28
问题 I have an stored procedure returning data from multiple tables. in nhibernate we create class for each table. is it required to create class for each table it is returning and then relating that class with each other. is there any other way of doing it like creating a class that contain all the fields returned by stored procedure thanks 回答1: I haven't worked with stored procedures, but you can definitely create a class that maps to a view and not just to a table. By the way, if you're using

Fluent nHibernate map HasMany to Entity/Table with no Primary Key

亡梦爱人 提交于 2019-12-25 03:47:08
问题 I am having the worst trouble trying to setup a HasMany relationship to an entity backed by a table with no primary key. ClassA has a CompositeId . To circumvent the lack of a primary key on ClassB , I tried to create a CompositeId on ClassB that was comprised all of the columns in the table. No matter what I've tried, nothing has worked. These are my classes and mappings. public class ClassA { public virtual int a_1_id {get;set;} public virtual string a_2_id {get;set;} public virtual IList

Site down: error log pattern of login failure x20, then invalid object name x20, then again login failure x20

孤街醉人 提交于 2019-12-25 03:26:34
问题 Our Orchard CMS with multi-tenancy just went down. We have since brought it back online by restoring a version of the database, and then recycling the application pool. Communicating with the restored database continued to fail until we recycled the app pool. The post-mortem analysis of the error log from yesterday had zero errors, and the error log from today has about forty errors with the following pattern: About 20 SqlException errors reporting "invalid login" for two of the tenant

XSockets.Net - how to manage NHibernate Session Context

别等时光非礼了梦想. 提交于 2019-12-25 03:24:33
问题 I wonder what is the best way to manage NHibernate Session Context when using NH data layer from Xsockets controller. Particularly I refer to self hosted winservice/console application or Azure worker role, where HTTPContext is not available. Of course there is always an option to create and dispose session per call, but that means a performance hit, so better reuse sessions in some way. My controller provides API for CRUD operations in underlying NH repository and is pushing updates to

Is this possible using NHibernate or Linq to SQL?

主宰稳场 提交于 2019-12-25 03:18:15
问题 Is it possible to do ORM mapping between classes and the DB using Linq to SQL or NHibernate just by using attributes on the models? For eg: If you use Parse.com as the backend, establishing a relationship between the DB and the class is as simple as: [ParseClassName("itemsForSale")] //Name of the table public class Item : ParseObject { [ParseFieldName("userId")] //Name of the column public string UserId { get { return GetProperty<string>(); } set { SetProperty<string>(value); } } } Nothing

Fluent nhibernate m-to-m mapping with external table

谁说胖子不能爱 提交于 2019-12-25 03:18:05
问题 I have two tables in Oracle Entity ---------- **EntityId** NUMBER(9), **EntityName** VARCHAR2 EntityLinks -------------- **EntityLinkId** NUMBER(9),**ParentEntityId** NUMBER(9), **ChildEntityId** NUMBER(9) Table EntityLinks will store ManyToMany relationship between various entities. ParentEntityId and ChildEntityId are having foreign key relationship with Entity . I have below a below class for Entity as well public class Entity { public virtual int EntityId {get; set} public virtual IList

Anyone using ASP.NET MembershipProvider with Nhibernate?

天大地大妈咪最大 提交于 2019-12-25 03:14:31
问题 I'm trying to implement Membership controls in a mvc 2 application and i'm having trouble dealing with the MembershipUser class. I have my own data store (in Postgresql) and I'm using Nhibernate to deal with it from C#. The thing is, I have my own user class, but I can't use it with any provider I found that implements Membership, because all the functions return the predefined MembershipUser class and cannot return my own. I'm losing my mind here, is there any way i can work with this, or

Problem connecting to MySQL from NHibernate

為{幸葍}努か 提交于 2019-12-25 03:13:47
问题 I am using NHibernate 3.0 with MySQL as the database. On my localhost, I can connect to the database and do everything I want to. However, whenever I upload the files to the production server, I get an error which states: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL

How to get results that begin with a certain letter?

☆樱花仙子☆ 提交于 2019-12-25 03:12:56
问题 I have a method similar to the following, which I need to return all Groups that begin with the letter I'm passing in: public IList<CompanyGroupInfo> GetGroupByQuery(string letter) { IList<CompanyGroupInfo> result = null; result = _session .CreateCriteria<CompanyGroupInfo>() .Add(SqlExpression.Like<CompanyGroupInfo>(g => g.Name, letter)) .List<CompanyGroupInfo>(); return (result.Count > 0) ? result[0] : null; } I'm brand new to NHibernate, so I don't really know what to do here. In my mind,