fluent

NHibernate taking a long time to run query

回眸只為那壹抹淺笑 提交于 2019-12-21 05:19:25
问题 This is being done using Fluent NHibernate I've got a NHibernate lookup that is retrieving data from one table. If i take the generated sql and run it through query analyzer, it takes ~18ms to run. Using NHProfiler, i'm getting the duration of this query as ~1800ms - 100 times longer than sql ! Query duration - Database only:1800ms - Total: 1806ms The object that is being populated contains a child class, but this child is being loaded from the NHibernate 2nd level cache The data that is

fluent nhibernate named-query without using hbm file for the map

天大地大妈咪最大 提交于 2019-12-21 04:14:11
问题 I am needing to create a named-query, and use it with one of the maps, that i currently have defined as a fluent map. is it possible to continue using the fluent map, and be able to create the named-query dynamically in code? or, is switching to a hbm map the only option? 回答1: Maybe I'm misreading the question, but you don't have to switch to hbm mapping completely. You could continue to use fluent NHibernate to map classes and use hbm for named queries only. In your configuration, you'd then

Any Fluent API tutorials that use EF Database-First approach to explain the subject?

大城市里の小女人 提交于 2019-12-21 02:44:05
问题 There are many tutorials on Fluent API, but they all explain it using Entity Framework Code-First code examples. Since I don't know Code-First, do you know of any Fluent API tutorials that would explain the subject using EF Database-First approach? Thank you 回答1: There are no tutorials which would explain the Fluent API together with Database-First approach because Fluent API is made only for Code-First approach. You don't need the Fluent API if you want to create your model via Database

How to write HtmlHelper in Fluent syntax

早过忘川 提交于 2019-12-21 02:38:04
问题 I have a simple tag builder that looks like this: public static MvcHtmlString Tag(this HtmlHelper helper, string tag, string content) { var tagBuilder = new TagBuilder(tag){InnerHtml = content}; return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.NormalTag)); } And, I can use it like this: @Html.Tag("em", Model.Title) which produces: <em>The Title</em> How can this be written to use a Fluent Syntax so it's use would look like this: @Html.Tag("em").Content(Model.Title) 回答1: You have

Fluent NHibernate join single column from another table

ぐ巨炮叔叔 提交于 2019-12-20 18:29:11
问题 I'm using Fluent NHibernate and have two tables; Customer [ID, Name, LanguageID] Languages [ID, Description] I have a Customer entity with the following properties; ID, Name, LanguageID, Language What I would like to do is to join to the Languages table to get the language description and put it in the language property of the customer entity. I have tried using Join but I can't get it to use the LanguageID field on the customer table to join to the Languages table - it keeps wanting to use

Rollback to a specfic Migration in FluentMigrator

空扰寡人 提交于 2019-12-20 06:51:20
问题 Suppose I have crated a three Table using FluentMigrator and gave them version Number 1, 2, 3 respectively. Now Is there any way to rollback till version 2. I mean After rollback I should have Table 1 and 2 but not 3. 回答1: Here is a batch file I use with the command line runner tool @echo off if "%1" == "rollback" goto rollback if "%1" == "" goto migrate if "%1" == "version" goto version if "%1" == "down" goto down goto error :migrate migrate -db SqlServer2014 -connection "Server=[YOUR

Rollback to a specfic Migration in FluentMigrator

江枫思渺然 提交于 2019-12-20 06:50:46
问题 Suppose I have crated a three Table using FluentMigrator and gave them version Number 1, 2, 3 respectively. Now Is there any way to rollback till version 2. I mean After rollback I should have Table 1 and 2 but not 3. 回答1: Here is a batch file I use with the command line runner tool @echo off if "%1" == "rollback" goto rollback if "%1" == "" goto migrate if "%1" == "version" goto version if "%1" == "down" goto down goto error :migrate migrate -db SqlServer2014 -connection "Server=[YOUR

Java inherited Fluent method return type in multiple level hierarchies

旧时模样 提交于 2019-12-20 03:13:41
问题 So following the solution described in Java - Inherited Fluent method return type to return incident class' type, not parent's. I want to extend it to multiple levels. The solution works in one level obviously. Here is compiled and runnable code (no dependencies): public enum X { ; static interface BaseFoo<T, S extends BaseFoo<T, S>> { S foo(); } static interface Foo<T> extends BaseFoo<T, Foo<T>> { void foo1(); } static abstract class AbstractFooBase<T, S extends BaseFoo<T, S>> implements

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

Java - Inherited Fluent method return type to return incident class' type, not parent's

给你一囗甜甜゛ 提交于 2019-12-19 07:36:11
问题 When you employ a fluent approach you might have the following scenario: public class Foo<T extends a>{ public Foo<T> someMethod(){ System.out.println("foo"); return this; } } public class Bar<T extends b> extends Foo<T> { public Bar<T> barMethod(){ System.out.println("bar"); return this; } } public class a{} public class b extends a{} A strength of a fluent interface is that you can chain method invocations, but whilst Bar has inherited someMethod(), the return type is Foo not Bar which