nhibernate

NHibernate data retrieve problem

时光总嘲笑我的痴心妄想 提交于 2019-12-25 04:56:14
问题 These codes are working well when saving data. But it is unable to retrieve data from b_TeacherDetail -table. For example: TeacherRepository tRep = new TeacherRepository(); Teacher t = tRep.Get(12); Here, t.TeacherDetail is null . But I know that there is an entry in the b_TeacherDetail -table for teacher-id 12. Why? My tables are: Teacher {ID, Name, IsActive, DesignationID, DepartmentID} TeacherDetail {ID, TeacherID, Address, MobileNo} Teacher.cs public class Teacher { public virtual int ID

NHibernate TDD with oracle in ASP.Net

血红的双手。 提交于 2019-12-25 04:55:30
问题 I am working on NHibernate with oracle in ASP.Net. Now i am trying TDD(Test Driven Development). Can you tell me the best way to develop the TDD for NHibernate with oracle? I am using MbUnit with microdesk but it is not better approach for oracle but SQL server. Please give suggestions... 回答1: When you're talking about doing TDD, you're talking unit testing and integration testing. For unit testing there is no database involvement at all so any testing tools will work. For integration testing

How to check if the collection is empty in NHibernate (HQL)?

微笑、不失礼 提交于 2019-12-25 04:37:23
问题 I have a following HQL query: SELECT s.id FROM stack s WHERE s.category is not empty Basically, s.category is a one-to-many join to another table (Category). I need to check whether the collection is empty or no. I can do it in c# code (just run through all of the Stacks and check if Stack.category.count > 0. Is there any HQL way to do so? Thank you! 回答1: I think this syntax works here: from stack s where exists elements(s.category) 来源: https://stackoverflow.com/questions/1105011/how-to-check

Will my session be automatically closed?

天涯浪子 提交于 2019-12-25 04:37:19
问题 Edit Orignal Title: My transaction is closed by the time it gets to my Repo. What am I doing wrong? I got a answer to my origanl questions(I forgot to open the transaction lol). Now I am wondering if my code is automatically closing the session or if I have to somehow tell it to do this. Hi I am using mvc 3.0, nhibernate, fluent nhibernate and ninject 2.0 Global.asax // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit http://go.microsoft.com/?LinkId=9394801 public class

Mapping Error in NHibernate

前提是你 提交于 2019-12-25 04:34:38
问题 I am trying to use NHibernate to connect to a Northwind database. But for some reason, I am not able to load the Entity Type. This is my Entity class public class Product { public virtual Int32 ProductId { get; set; } public virtual String Desc { get; set; } } Here is my Mapping <class name="Product" table="Products"> <id name="ProductId" column="ProductId" type="Int32"> <generator class="identity"></generator> </id> <property name="Desc" column="ProductName" type="String" length="60"> <

Has anyone used any .Net code generation frameworks in Mono? (Subsonic, .netTiers, etc..)

主宰稳场 提交于 2019-12-25 04:34:11
问题 Mono appears to have really come a log way since the last time I really used it. I'm interested in doing some ASP.Net development using Mono. I have used .netTiers/CodeSmith at work and really enjoy the speed with which code generation gives you a clean working data access layer. The question is has anybody used any code generation with Mono? I am open to learning something like SubSonic or NHibernate if those work better with Mono. Thanks in advance for any help. 回答1: I have used subsonic

Has anyone used any .Net code generation frameworks in Mono? (Subsonic, .netTiers, etc..)

荒凉一梦 提交于 2019-12-25 04:34:05
问题 Mono appears to have really come a log way since the last time I really used it. I'm interested in doing some ASP.Net development using Mono. I have used .netTiers/CodeSmith at work and really enjoy the speed with which code generation gives you a clean working data access layer. The question is has anybody used any code generation with Mono? I am open to learning something like SubSonic or NHibernate if those work better with Mono. Thanks in advance for any help. 回答1: I have used subsonic

<map> with <index-many-to-many> won't save in NHibernate

不打扰是莪最后的温柔 提交于 2019-12-25 04:32:08
问题 I have the following mapping: <?xml version='1.0' encoding='utf-8'?> <hibernate-mapping assembly='Core' namespace='Core.Models' xmlns='urn:nhibernate-mapping-2.2'> <class name='Basket'> <id name='Id' column='id'> <generator class='native'/> </id> <property name="ExternalId" /> <map name="Items" table="BasketItems" cascade="save-update"> <key column="BasketId" /> <index-many-to-many class="Product" column="ProductId" /> <element column="Quantity" type="System.Int32" /> </map> </class> <

Fluent Nhibernate Many to Many relationship issue

删除回忆录丶 提交于 2019-12-25 04:22:59
问题 I have a situation where I have three tables in our database. One to contain customers, one contains customer groups, and then a table to link them together. I am having issues where my nHibernate query wont join them correctly, and I am not sure if I am missing something. Mapping for the Customer Groups public CustomerGroupMapping() { Table("tbCustomerGroups"); // TODO: Revisit Lazy loading //LazyLoad(); Id(x => x.customerGroupId) .GeneratedBy.Identity() .Column("Customer_Group_ID"); Map(x =

How to a NHibernate subquery in Where clause with LINQ?

狂风中的少年 提交于 2019-12-25 04:12:28
问题 I'm trying to write a correlated subquery in the where clause like this: var foo = from d in session.Query<Document>() where true == ( from a in session.Query<ACLEntry>() where a.Id == d.Id || a.Id == null select a.Result ).FirstOrDefault() select d; The expected SQL output is very similar to this unanswered question on SO. I think the Linq statement itself is fine because I can get it to run in LinqPad where I was prototyping. But NHibernate throws me these mysterious errors: ERROR