nhibernate

Using SharpArchitecture's NHibernateSession in conjunction with a different thread

痴心易碎 提交于 2020-01-13 05:08:11
问题 I'm using SharpArchitecture in an ASP.NET MVC 3 application. Everything works wonderfully. Using SharpArchitecture's NHibernateInitializer to initialize a new Session per request like so: protected void Application_BeginRequest(object sender, EventArgs e) { NHibernateInitializer.Instance().InitializeNHibernateOnce(InitializeNHibernateSession); } private void InitializeNHibernateSession(ISessionStorage sessionStorage) { NHibernateSession.ConfigurationCache = new

NHibernate: HQL and UserTypes as query parameters

拜拜、爱过 提交于 2020-01-13 04:11:51
问题 I'm using a database that has a weird date format. I wrote a UserType to transfer standard .NET DateTime to/from the weird format and it works fine. I've normally used ICriteria queries but decided to try IQuery using HQL on this project. I ran into a problem that query doesn't translate parameters to the appropriate UserType. eg: IQuery query = session.CreateQuery("from OfflineShipmentLineItem as line join fetch line.Shipment as shipment join fetch line.Extension where shipment.ShipmentDate

NHibernate linq provider datediff

假装没事ソ 提交于 2020-01-13 02:54:29
问题 Is where a way to write something like this: public class Item { public DateTime Start { get; set; } public DateTime Finish{ get; set; } } Sessin.Query<Item>.Where( x => x.Start.AddHours( 3 ) > x.Finish ); Now i get an exception [NotSupportedException: System.DateTime AddHours(Double)] 回答1: There is no easy way to make your LINQ query work. The problem with your scenario is that NHibernate doesn't know how to translate DateTime.AddHours(double hours) method. But can you use HQL to write a

Can I use SQL functions in NHibernate QueryOver?

不羁的心 提交于 2020-01-12 14:12:31
问题 I have been searching the internet and can't find an example on how to use the queryover of nhibernate 3.0 For example I would like to use the string functions on the where clause of the queryover ex: var item = Query.Where(x => x.Name.ToLower() == name.ToLower()).FirstOrDefault(); But this doesn't work, because nhibernate can't understand the ToLower, so how can extend the dialect in a way that this becomes possible? 回答1: session.QueryOver<Foo>() .Where(Restrictions.Eq( Projections

Could not load file or assembly NHibernate.XmlSerializers [closed]

孤街醉人 提交于 2020-01-12 12:12:19
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I am trying to create a custom membership and role provider. The code for this seems to be fine, but when I try to go to the Security section of the Web

Could not load file or assembly NHibernate.XmlSerializers [closed]

这一生的挚爱 提交于 2020-01-12 12:09:31
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I am trying to create a custom membership and role provider. The code for this seems to be fine, but when I try to go to the Security section of the Web

JsonSerializationException on lazy loaded nHibernate object in WebApi when called from Angularjs service

放肆的年华 提交于 2020-01-12 08:24:48
问题 I am calling a WebApi controller Get method from an Angularjs service. The angular service: app.service('MyService', ['$http', function ($http) { var getMyObjects = function () { var myObjects; var promise = $http.get('/api/objects/').success(function (data) { myObjects = data; }).error(function (data, status, headers, config) { }); return promise; }; return { myObjects: myObjects }; }]); The WebApi Get method: public class ObjectsController : ApiController { public IEnumerable<MyObject> Get(

ORM and SOA in the .NET world

爷,独闯天下 提交于 2020-01-12 07:10:59
问题 From my experience the major ORM frameworks for .NET (NHibernate, LinqToSql, Entity Framework) work best when they keep track of loaded objects. This works fine for simple client-server applications, but when using three- or more tier architecture with Web Services in a Service Oriented Archtitecture, this is not possible. Eventually, by writing a lot of code to do the tracking yourself it could be done, but isn't ORM supposed to simplify DB access? Is the idea to use ORM in service oriented

ORM and SOA in the .NET world

可紊 提交于 2020-01-12 07:09:27
问题 From my experience the major ORM frameworks for .NET (NHibernate, LinqToSql, Entity Framework) work best when they keep track of loaded objects. This works fine for simple client-server applications, but when using three- or more tier architecture with Web Services in a Service Oriented Archtitecture, this is not possible. Eventually, by writing a lot of code to do the tracking yourself it could be done, but isn't ORM supposed to simplify DB access? Is the idea to use ORM in service oriented

How would I design a repository to handle multiple data access strategies?

别等时光非礼了梦想. 提交于 2020-01-12 06:24:18
问题 What would a skeleton design look like for a repository able to support multiple database layers using ASP.NET MVC and C#? I want to see what a design would look like if I support both LINQ to SQL and NHibernate. How would I create my database object, and call a method on it in my BLL layer? 回答1: The repository pattern is probably the best solution for this. You would define an interface for each repository, then create concrete repositories for Linq2Sql and NHibernate implementations, e.g.