fluent-nhibernate

Error using $expand with NHibernate and webapi + OData

為{幸葍}努か 提交于 2019-12-08 05:21:28
When you run the query {{odata-url-prefix}}/ArquivosVenda(2)?$expand=Vendas an error is generated: { "odata.error": { "code": "", "message": { "lang": "en-US", "value": "An error has occurred." }, "innererror": { "message": "Argument types do not match", "type": "System.ArgumentException", "stacktrace": " at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices

How do I test extension method of Nhibernate which does not return the value even after specifying return in fakeiteasy?

て烟熏妆下的殇ゞ 提交于 2019-12-08 04:50:31
问题 I have a class like below where using Fluent Nhibernate I am getting data from database public class MyActualClass { public MyActualClass(ISessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public List<AnnualInformation> GetData() { using (session = sessionFactory.OpenSession()) { var result = session.QueryOver<AnnualInformation>() .SelectList(list => list .Select(x => x.Id) .Select(x => x.CreationDate) .Select(x => x.AnnualAmount) .Select(x => x.AnnualCurrency) .Select(

NHibernate + Spring.NET lazy loading failed - no session

僤鯓⒐⒋嵵緔 提交于 2019-12-08 04:43:23
问题 I use Spring.NET AOP for transaction and session management with NHibernate. When user makes several requests too quick - lazy loading is failed with exception "no session or session was closed". I use SpringSessionContext as CurrentSessionContext in NHibernate configuration public class FluentSessionFactory : LocalSessionFactoryObject { protected override ISessionFactory NewSessionFactory(Configuration config) { var conf = Fluently .Configure() .Database( MsSqlConfiguration .MsSql2008

Fluent nHibernate - How to map a non-key column on a junction table?

柔情痞子 提交于 2019-12-08 04:37:46
问题 Taking an example that is provided on the Fluent nHibernate website, I need to extend it slightly: (source: fluentnhibernate.org) I need to add a 'Quantity' column to the StoreProduct table. How would I map this using nHibernate? An example mapping is provided for the given scenario above, but I'm not sure how I would get the Quantity column to map to a property on the Product class: public class StoreMap : ClassMap<Store> { public StoreMap() { Id(x => x.Id); Map(x => x.Name); HasMany(x => x

How do I update the primary key using nhibernate

丶灬走出姿态 提交于 2019-12-08 02:37:47
问题 The primary key for one of my tables is a string. THe string is a code which i would like to update at some point of time. How can I do this in nhibernate. Please note there is a foreign key connected to this column which I need to cascade updates to. For the sake of discussion let us assume my mapping is as below public class Code { public virtual string Id { get; set; } public virtual string Name { get; set; } public class CodeMap : ClassMap<Code> { public CodeMap() { Table("BusinessCode");

Serialize nHibernate query to JSON

倖福魔咒の 提交于 2019-12-08 02:34:28
问题 In delving into Fluent nHibernate, I discovered a potential breaker for using it... Given the following POCO code. public class Customer { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Details Details { get; set; } } public class Details { public virtual int Id { get; set; } public virtual IList<Orders> Orders { get; set; } } public class CustomerMap : ClassMap<Customer> { // perform mapping } public class DetailsMap : ClassMap<Details> { //

NHibernate config properties in Fluent NHibernate

本小妞迷上赌 提交于 2019-12-08 01:54:52
问题 I am considering using Fluent NHibernate for my project and I haven't found any documentation on whether FH supports NHibernate settings such as show_sql and prepare_sql. I could live without show_sql in a pinch, but prepare_sql is important for ensuring good performance at run time. Can anyone tell me if it's possible to configure these settings in Fluent NHibernate? 回答1: Yes, you can. Fluently.Configure() .Database(ConfigureDatabase()) .Mappings(ConfigureMapping) .ExposeConfiguration

How do I map a dictionary using Fluent NHibernate automapping?

烂漫一生 提交于 2019-12-08 01:38:30
问题 I have an entity like so: public class Land { public virtual IDictionary<string, int> Damages { get; set; } // and other properties } Every time I try to use automapping with the following code: var sessionFactory = Fluently.Configure() .Database(SQLiteConfiguration.Standard.InMemory) .Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Land>)) .BuildSessionFactory(); I get the following error: {"The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic

Fluent NHibernate- ClassMap inheritance?

泪湿孤枕 提交于 2019-12-08 01:20:22
问题 In an earlier question (unrelated to Fluent NHibernate- I've switched as a result of my problem) I outlined a table layout issue I'm having where I need to split my Listing entities across a number of tables depending on what country they're from. It's for performance reasons- effectively, I want tables for Listing_UK, Listing_FR, etc. Now, I thought I'd hit the jackpot with Fluent, and I'm 90% there- but I've got stuck. I have a Listing class, and a Listing_UK class that inherits from it. As

Fluent NHibernate mapping a CompositeId and Querying with SetProjection

不羁的心 提交于 2019-12-08 00:27:32
问题 I have two tables (Section and SectionList) that are related by a many to many table (Membership). Since there is an extra property in the many to many table, i have to break it out into its own entity: public MembershipMap() { UseCompositeId() .WithKeyReference(x => x.Section, "SectionId") .WithKeyReference(x => x.SectionList, "SectionList"); Map(x => x.Status); } And SectionList is mapped as follows: public SectionListMap() { Id(x => x.Id) .WithUnsavedValue(0); HasMany(x => x.Memberships)