fluent-nhibernate

Query-only properties with Fluent NHibernate

删除回忆录丶 提交于 2019-12-11 03:45:51
问题 I can't find how Nhibernate feature described in Ayende's blog works with Fluent NHibernate. As far as I understand, I can map pseudo-field which value is a result of any hql query. Is this correct? How this feature can be used with Fluent Nhibernate? I tried google, but unsuccessful. Code samples or links to them would be much appreciated. 回答1: According to this ticket it works: http://code.google.com/p/fluent-nhibernate/issues/detail?id=259 There is a sample there, but I haven't tested it.

How to fill just required properties of entity (FluentNHibernate)

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:29:12
问题 I am using FluentNHibernate to access to my database. I would like to implement next - just required properties of my entity should be filled. By example, in one case all properties should be filled, in second case repository should return entity with ID and Name properties only. Does it make sence? I see point when I can implement a few mappings for entity - every mapping according to case. Then I get a few ISessionFactory'ies - repository uses required ISessionFactory to cover required case

How can i get NHibernate to give me the SQL it would generate for an insert / update instead of executing it?

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:14:35
问题 I'm using NHibernate to map some very simple entities to three tables. My program needs to have a mode where it outputs the SQL it would execute to insert or update these tables, so that the SQL can be saved to a script file, to be later executed manually. This is similar to this question (which has a very nice answer): How can I have NHibernate only generate the SQL without executing it? Only that question is about SELECT, I need kind of the same but for INSERT / UPDATE. This also needs to

NHibernate QueryOver

亡梦爱人 提交于 2019-12-11 02:54:57
问题 I've searched around but not found what I am doing wrong here. I have object C which holds a list of object L, object C also holds a reference to class R. From object L I want to find object R. I'm trying to do this but I only get null using this code: L is already an instanced object a function receives. var t = SessionController.CurrentSession.QueryOver<C>() .Where(c => c.Id == L.C_Id) .JoinQueryOver<R>(c => c.R) .Select(c => c.R).SingleOrDefault(); Any idea what I'm doing wrong here would

NHibernate second level cache caching entities with no caching configuration

大兔子大兔子 提交于 2019-12-11 02:42:38
问题 I have configured second level cache on the session factory. However for the POCO entity I have not enabled caching. I am using Fluent NHibernate for configuring the SessionFactory and the POCO entities. Here is the configuration of the session factory: var cfg = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString) .Provider("NHibernate.Connection.DriverConnectionProvider, NHibernate") .Dialect<CustomMsSql2008Dialect>() .Driver<SqlAzureClientDriver>()

Storing images in database results in partial image

随声附和 提交于 2019-12-11 02:22:24
问题 I'm trying to store images in a sql server database. I've got a column in an Image table which stores the data and is of type varbinary(max). I'm using NHibernate to access the database. The loading of the image into the code and converting it to a buffer array works fine. When I store the image in the database, no matter what size image above 30kb that I put in, only part of the image is saved. I checked the data stored in the database and all images have the same amount of data stored so my

self-reflexive n:m relation using composite keys in nhibernate

六月ゝ 毕业季﹏ 提交于 2019-12-11 02:16:18
问题 I have a legacy database with 3 tables like this: (source: bilder-hochladen.net) The Items table contains all the Items in a Plan. The Structure table defines the relation between the items. A parent item is defined by company , year , planId and parentItem of table structure mapping to company , year , planId and id of table item . A child item is defined by company , year , planId and childItem of table structure mapping to company , year , planId and id of table item . I am searching for a

Fluent NHibernate automap list of strings with nvarchar(max)

谁说胖子不能爱 提交于 2019-12-11 02:14:26
问题 I am using Fluent NHibernate 1.2 for NHibernate 3.1. I have a class: public class Marks { public virtual int Id { get; set; } public virtual IList<string> Answers { get; set; } } In the mapping for the Marks class, I have: HasMany(m => m.Answers).Element("Value"); When the tables are created, an "Answers" table get created with the following columns: Marks_id (FK, int, not null) Value (nvarchar(255), null) What I would like to do is have the Value be nvarchar(max). I'd prefer not doing this

NHibernate manually control fetching

雨燕双飞 提交于 2019-12-11 02:05:59
问题 I am using NHibernate and I want to control fetching related entities manually. Here is my sample entity public class Post { public virtual long Id { get; set; } public virtual string Title { get; set; } public virtual User User { get; set; } public virtual IList<Like> Likes { get; set; } public virtual IList<Tag> Tags { get; set; } } The behvaiour I expect is as follows: session.Query<Post>().ToList(); After this kind of query I want Post entities to have: Primitive properties are set User

linq to entities vs fluent nhibernate vs linq to sql (Help)

独自空忆成欢 提交于 2019-12-11 01:57:48
问题 I have to build a website for a news channel.. Please help me decide which technology to use for data operations? 1) Linq to Entities 2) Linq to SQL 3) Fluent NHibernate 4) ADO.Net Website will be based on ASP.Net MVC and C#. Main Issues: 1) Should be easy to maintain and scale. 2) Good Performance Please express your view with an example if possible.. Thanks Chitresh 回答1: Pro and cons: LINQ To Entities Allows you to add another layer of abstraction (entity) instead of mapping directly to