fluent-nhibernate

Fluent nHibernate error - Could not compile the mapping document: (XmlDocument)

拟墨画扇 提交于 2019-12-19 21:44:11
问题 I have read all questions about Fluent nHibernate and didnt find answer for that. I am trying to run the Getting Started tutorial here and I get this error: Could not compile the mapping document: (XmlDocument) The error happens when I am running the CreateSessionFactory: private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database(SQLiteConfiguration.Standard .UsingFile(DBfile)) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())

Is the default behavior with Fluent NHibernate to lazy load HasMany<T> collections?

亡梦爱人 提交于 2019-12-19 17:14:40
问题 when I am setting up my fluent mappings, what is the default for collections? Do I need to explicitly set them as lazy-load, or is that the default? 回答1: Note this is changed as of current day to be inline with NHibernate standards which is lazy loading is enabled by default for everything. 来源: https://stackoverflow.com/questions/316264/is-the-default-behavior-with-fluent-nhibernate-to-lazy-load-hasmanyt-collectio

Fluent NHibernate: How to map an entire class as ReadOnly?

徘徊边缘 提交于 2019-12-19 12:24:26
问题 I have a few classes that read from very delicate tables, which is why I want them to be used by NHibernate as "ReadOnly". Establishing .ReadOnly() on each field map is really sloppy, and I'm not sure I trust it. How do I setup a class to be entirely readonly, as I can easily do with traditional XML mappings? Edit : The answer does work. I expected it to throw an exception if I tried to save over a ReadOnly() object, but it just silently does so. Thanks. 回答1: With Fluent NHibernate, it's as

Fluent NHibernate (1.2.0.712) export mappings to HBM not working / not respecting conventions

↘锁芯ラ 提交于 2019-12-19 10:26:57
问题 The HBM export function in Fluent NHibernate does not seem to work. If I call FluentMappingsContainer.ExportTo, the generated mappings come out incorrect, and I get the following exception: FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. My configuration code looks like this: MsSqlConfiguration database = MsSqlConfiguration.MsSql2008

Fluent NHibernate and computed properties

南楼画角 提交于 2019-12-19 09:06:21
问题 I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in a class along the lines of public virtual DateTime? LastActionTimeStamp { get { return Actions.Count == 0 ? null : Actions.OrderByDescending( a => a.TimeStamp).ElementAt(0).TimeStamp; } } This wasn't mapped with the rest of the properties, so I couldn't use it in an ICriteria restriction. I added an empty setter (as I read somewhere that doing so would include it in the mapping, which it does), but now I

Fluent NHibernate and computed properties

拜拜、爱过 提交于 2019-12-19 09:05:17
问题 I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in a class along the lines of public virtual DateTime? LastActionTimeStamp { get { return Actions.Count == 0 ? null : Actions.OrderByDescending( a => a.TimeStamp).ElementAt(0).TimeStamp; } } This wasn't mapped with the rest of the properties, so I couldn't use it in an ICriteria restriction. I added an empty setter (as I read somewhere that doing so would include it in the mapping, which it does), but now I

NHibernate/FluentNHibernate property bag

亡梦爱人 提交于 2019-12-19 08:58:43
问题 Given a Vehicle class and a VehicleProperty class... public class Vehicle { public virtual int Id { get; protected set; } public virtual string Registration { get; set; } private List<VehicleProperty> _properties = new List<VehicleProperty>(); public virtual IEnumerable<VehicleProperty> Properties { get { return _properties; } protected set{ _properties = new List<VehicleProperty>(value);} } public virtual void AddProperty(string name, string value) { _properties.Add(new VehicleProperty {Name

Fluent Nhibernate Automap convention for not-null field

允我心安 提交于 2019-12-19 06:31:36
问题 Could some one help, how would I instruct automap to have not-null for a column? public class Paper : Entity { public Paper() { } [DomainSignature] [NotNull, NotEmpty] public virtual string ReferenceNumber { get; set; } [NotNull] public virtual Int32 SessionWeek { get; set; } } But I am getting the following: <column name="SessionWeek"/> I know it can be done using fluent-map. but i would like to know it in auto-mapping way. 回答1: Thank you. Also, for reference properties ReferenceConvention

Fluent Nhibernate Automap convention for not-null field

。_饼干妹妹 提交于 2019-12-19 06:31:17
问题 Could some one help, how would I instruct automap to have not-null for a column? public class Paper : Entity { public Paper() { } [DomainSignature] [NotNull, NotEmpty] public virtual string ReferenceNumber { get; set; } [NotNull] public virtual Int32 SessionWeek { get; set; } } But I am getting the following: <column name="SessionWeek"/> I know it can be done using fluent-map. but i would like to know it in auto-mapping way. 回答1: Thank you. Also, for reference properties ReferenceConvention

Is there any data on NHibernate vs Fluent NHibernate startup performance?

橙三吉。 提交于 2019-12-19 04:09:30
问题 In short, what works faster: SessionFactory precompiling XML configuration, or Fluent NHibernate providing configuration programmatically ? 回答1: Fluent NHIbernate creates the XML documents and Sessionfactory under the hood, so it is slower than not using Fluent NHibernate. Why do you ask? 回答2: My personal experience has been that the building of the Configuration object (which is unavoidable* regardless of whether Fluent is used) generally dwarfs the time required to setup a