nhibernate

Why would my asp.net-mvc site using nhibernate simply stop doing updates and deletes?

断了今生、忘了曾经 提交于 2020-01-14 14:28:32
问题 I have a very simple CRUD asp.net-mvc site that uses nhibernate to interface with a mySQL db. I am using the UnitOfWork and Repository patterns. After upgrading to MVC 4 and the latest nhibernate and mySQL versions (via nuget) I am suddenly seeing a weird issue where updates and deletes have stopped working. Here is an example Delete code in my controller that stopped working: public ActionResult Delete(int id) { MyEvent c = _eventRepository.FindBy(id); _unitOfWork.Begin(); _eventRepository

NHibernate: Lazyload single property

…衆ロ難τιáo~ 提交于 2020-01-14 14:17:48
问题 I have currently moved my blogengine over from Linq2Sql to NHIbernate. I'm stuck at the following performance problem: I got one table: 'Posts', that has Id, Title, PostContent, DateCreated collumns and so on. The problem is that, when I'm creating the "Recent posts list", I don't want the whole PostContent . In Linq2Sql you can set lazy loading on a single property, so it won't be part of the SQL query until you actually ask for the property. I tried doing this with Fluent NHibernate, by

LINQ to NHibernate - .GroupBy().Skip().Take() cause an exception

≯℡__Kan透↙ 提交于 2020-01-14 14:16:14
问题 NHibernate version 3.3.1.4000 Query: IQueryable<Activity> activities = _repository.GetList<Activity>(); IQueryable<ActivityStatistic> statistics = activities .GroupBy(activity => activity.ActivityLicense.SerialNumber) .Select(grouping => new ActivityStatistic { ActivityCount = grouping.Count(), LicenseCode = grouping.Key }) .OrderBy(stat => stat.LicenseCode); List<ActivityStatistic> result = statistics .Skip(request.StartIndex) .Take(request.Count) .ToList(); If I comment Skip/Take code, it

LINQ to NHibernate - .GroupBy().Skip().Take() cause an exception

两盒软妹~` 提交于 2020-01-14 14:16:07
问题 NHibernate version 3.3.1.4000 Query: IQueryable<Activity> activities = _repository.GetList<Activity>(); IQueryable<ActivityStatistic> statistics = activities .GroupBy(activity => activity.ActivityLicense.SerialNumber) .Select(grouping => new ActivityStatistic { ActivityCount = grouping.Count(), LicenseCode = grouping.Key }) .OrderBy(stat => stat.LicenseCode); List<ActivityStatistic> result = statistics .Skip(request.StartIndex) .Take(request.Count) .ToList(); If I comment Skip/Take code, it

NHibernate 3.2 By Code (Conformist) ClassMapping For a Dictionary Property

限于喜欢 提交于 2020-01-14 14:14:12
问题 Assume I have a class "SomeClass" that has a lookup dictionary: DataDictionary; I currently have a mapping in SomeClass.hbm.xml like this: <class name="SomeClass> <id name="ID" type="System.Guid"> <generator class="guid" /> </id> <map name="DictionaryProperty" table="SomeClass_Data"> <key column="SomeClassID" /> <index column="Key" type="System.String" /> <element column="Value" type="System.String" /> </map> </class> I want to use NHibernate's new (version 3.2) By Code mappings. How would I

How to set Nhibernate LINQ Command Timeout using Session.Query

半城伤御伤魂 提交于 2020-01-14 09:48:32
问题 Is anyone aware of a way to set the UnderlyingCriteria when using Session.Query ? I'm trying to set a more restrictive command timeout (or query timeout) for one specific query and I am trying to avoid adding that constraint on the connection or other querys in the session. I've found in the old QueryOver functionality you could use something like this // QueryOver returns a IQueryOver<T,T> an nHibernate class // with access to UnderlyingCriteria var query = Session.QueryOver<Puppy>(); query

FluentNHibernate or port to NHibernate mapping by code

这一生的挚爱 提交于 2020-01-14 08:07:08
问题 I have several projects using NH and FNH to generate the mappings (some Fluent some Automapped). There are still some bugs and missing features i need, but it seems that FNH could die because of mapping-by-code integrated into NHibernate. Question: Contribute to FNH or to migrate the mappings to mapping-by-code or confORM and fixing problems/implementing features there? 回答1: At our office, we have been using NHibernate for 3 years now. We've been thinking about making a move to Fluent

WCF RIA SubmitChanges doesn't send master properties back to the server side

半世苍凉 提交于 2020-01-14 06:09:26
问题 Look, I have these pretty simple model Master-Detail: Hand is master of Fingers (finger is a detail of hand) So on the client side: Hand hand = domainService.Hands[0]; // get some hand, doesn't matter ... Finger f = new Finger() { f.Id = Guid.NewId() }; f.Hand = hand; // make connection !! domainService.Fingers.Add(f); domainService.SubmitChanges(OnSubmitCompleted, null); // error is here On the Server Side: public void Insert<T>(T obj) { try { using (ISession session = _factory.OpenSession()

storing images in db and map them with nhibernate

别来无恙 提交于 2020-01-14 04:27:47
问题 how to store images in db and map them with nhibernate 回答1: You can map binary data using the binary type which equates to a byte[] array in code and a varbinary in the database. This may cause performance issues if you load a number of objects containing binary data or large objects because the objects will be kept in memory in the first level cache. This article discusses techniques to improve performance in this situation. 来源: https://stackoverflow.com/questions/808484/storing-images-in-db

Getting/building the SQL (with parameters) from NHibernate 3.2

瘦欲@ 提交于 2020-01-14 03:44:27
问题 I am working on a project that requires the following: Extract the full SQL query from a specific NHibernate 3.2 session. Perform specific actions on the query (i.e not necesserily log it) Do not affect NHibernate in the whole system to avoid introducing performance issues I checked several approaches, many of them already appearing on StackOverflow. Here are my options as I see now: Manual In the most naive and annoying solution, I can just follow the business logic and build the query