fluent-nhibernate

What is the difference between a nhibernate query cache and entity cache when using second level caching?

▼魔方 西西 提交于 2019-12-12 08:23:51
问题 I am trying to setup nhibernate second level caching and i see in this article, and i am trying to understand the difference between query caching and entity caching. It says you need to add Cache.ReadOnly(); or Cache.ReadWrite(); on every single entity mapping like this: public class CountryMap : ClassMap<country> { public CountryMap() { Table("dropdowns"); Id(x => x.Id, "pkey"); Map(x => x.Name, "ddlong"); Map(x => x.Code, "dddesc"); Where("ddtype = 'COUNTRY'"); //Informing NHibernate that

NHibernate dynamic mapping

ⅰ亾dé卋堺 提交于 2019-12-12 08:03:27
问题 I am looking for some way to dynamically map database tables classes in my application using nhibernate (or if some other ORM works then let me know). I am fairly new to nhibernate, I used entity frameworks in the past though. Most of my application will be using a static structures and fluent nhibernate to map them. However there are multiple database tables that will be needed to be created and mapped to objects at each install site. These will all have as a base structure (id,name etc)

Fluent Nhibernate Mapping for Sql Views

不羁岁月 提交于 2019-12-12 07:48:45
问题 i am using Fluent Nhibernate in asp.net mvc3 with c# i am working in following way to generate and map a class Mapping using FluentNHibernate.Mapping; using Com.Web.Domain; namespace Com.Web.Mapping { public class CompanyMap : ClassMap<Company> { public CompanyMap() { Id(x => x.id); Map(x => x.Name); } } } Class using System.Collections.Generic; using System; namespace Com.Web.Domain { public class Company { public virtual int id { get; set; } public virtual string Name{get;set} } } and in

Ignore public/internal fields for NHibernate proxy

筅森魡賤 提交于 2019-12-12 07:45:51
问题 I have some entity types that I would like to lazy load. However, they have some internal (assembly) fields they expose, but are not used outside that class. These fields are compiler generated (F#) and I cannot change them. The an example exception is: NHibernate.InvalidProxyTypeException: The following types may not be used as proxies: Mappings.MTest: field id@47 should not be public nor internal I understand why NHibernate is doing this, and how having fields, if I accessed them, would

nhibernate criteria - table name has double quotes

穿精又带淫゛_ 提交于 2019-12-12 06:17:20
问题 I am using Fluent NHibernate in my application. I have a criteria query that looks like this - var query = DetachedCriteria .For<table2>() .SetProjection(Projections.Distinct(Projections.Property("id"))) //.Add(Restrictions.Between("date_field", startDate, endDate)) .Add(Restrictions.Eq("id", 204010)); Add(Subqueries.In("id", query)); This errors out with the error - NHibernate.ADOException was unhandled Message=could not execute query I looked at the query and tried to run it, but it also

Fluent NHibernate? Am I doing this correctly?

一笑奈何 提交于 2019-12-12 06:15:20
问题 I am new to using Fluent NHibernate and NHibernate for the first time. I've used a custom written mapper since about 2000 that was written in house. Made a switch to LinqToSQL about 2 years ago, and about 6 months ago to Entities. I'd like to see what Fluent/NHibernate have to offer. However, I can't seem to get it to run correctly. The following is a copy of my classes, their references, the ClassMaps. Can someone tell me if this simple implementation is correct? This is my mappings and

Managing inheritance using Fluent NHibernate

こ雲淡風輕ζ 提交于 2019-12-12 06:12:59
问题 I am working on a rather strange scenario here : We have a class that users can search over them. For some performance reason I'd like to have a view in our database that practically provide the same information and I do the search over this view . For the sake of simplicity let say out class name is Entity : public class Entity{ ..... } We are passing the search filters as an Expression<Func<Entity,bool>> so I need my view be inherited from Entity then I have created an EntiyView class like

Getting ManyToMany relationship to load

廉价感情. 提交于 2019-12-12 05:58:12
问题 I have User object with a list of groups that it belongs to: public UserHeaderMap() { Table("USER_HEADER"); Id(x => x.Id, "USER_ID"); HasManyToMany(x => x.Groups) .Table("USER_GROUP_COMPOSITE") .ParentKeyColumn("USER_ID") .ChildKeyColumn("GROUP_ID") .Cascade.SaveUpdate() .Inverse(); } How do I need to modify my mapping or the way I'm retrieving my user object to fill the Groups list upon retrieval? I'm sure there are different options here but I'm not sure which is the best. The collection is

Fluent NHibernate FluentNHibernate.Mapping.Builders Namespace

穿精又带淫゛_ 提交于 2019-12-12 05:58:02
问题 I am using the latest version of Fluent NHibernate (1.2.0.712) retrieved over NuGet. Previously I have used the FluentNHibernate.Mapping.Builders Namespace to create mapping extensions similar to: public static class MappingExtensions { public static PropertyBuilder Text(this PropertyBuilder propertyBuilder) { propertyBuilder.Length(10000); return propertyBuilder; } public static PropertyBuilder Money(this PropertyBuilder propertyBuilder) { propertyBuilder.CustomType<MoneyUserType>(); return

How to use fluent nhibernate to map a value type collection?

心已入冬 提交于 2019-12-12 05:39:29
问题 ......... <property name="Title" /> <set name ="Contacts" lazy="false" table ="Ad_Contacts"> <key column="Ad_Id"></key> <element type ="String" column="Contact" not-null="true"></element> </set> ......... HasMany(x => x.Contacts).AsSet() , which is the statement I used for fluent nhibernate mapping. It doesn't work. Contacts is a collection of string. 回答1: You could try with the following map: HasMany<string>(x => x.Contacts).AsElement("Ad_Id"); 回答2: HasMany(x => x.Contacts).AsSet().KeyColumn