fluent

Private property mapping with fluent nhibernate

元气小坏坏 提交于 2019-12-03 14:15:29
I am getting exception mapping a private property.This is the situation: I have this in Entity.cs: privat int m_Inactive; and in EntityMap.cs I have : Map(x => Reveal.Property<Entity>("m_Inactive")).ColumnName.("INACTIVE"); But I get this error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Not a member access What could be the reason? Thanks. If you follow the examples on the wiki you'll see that you're supposed to use Map(Reveal.Member<YourEntity>("m_Inactive")) . Looks like in the latest version you're

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

蓝咒 提交于 2019-12-03 12:50:15
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? 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 include the entities and the hbms. _sessionFactory = Fluently.Configure() .Mappings(m => { m.FluentMappings

How to Design Fluent Async Operations?

梦想与她 提交于 2019-12-03 12:15:41
Async operations do not seem to play well with fluent interfaces which I prefer to code in. How can Asynchrony be combined with Fluent? Sample: I have two methods that previously returned a MyEntity but do not play well when change to Async. After I asyncfy them I have to await the result of the tasks, but I have to do that for each step added: MyEntity Xx = await(await FirstStepAsync()).SecondStepAsync(); There has to be a better way. Gusdor Some of the answers that deal with continuations are forgetting that fluent works on concrete instances that are returned from each method. I have

truncate all tables in laravel using eloquent

♀尐吖头ヾ 提交于 2019-12-03 10:51:28
Is there a way I could truncate all the tables in a db using eloquent or fluent in laravel 4? I do not want to specify table names, I just want to truncate all the tables. In other words empty all the tables. 1. Get all the table names $tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames(); 2. Loop through the array of table names and truncate with Schema Builder foreach ($tableNames as $name) { //if you don't want to truncate migrations if ($name == 'migrations') { continue; } DB::table($name)->truncate(); } In laravel 5, migrate:fresh will drop all the tables in

How to write HtmlHelper in Fluent syntax

两盒软妹~` 提交于 2019-12-03 09:15:11
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) You have to define a builder interface and implementation. I hope my example can provide some guidance: public static

Fluent NHibernate Newbie: Row was updated or deleted by another transaction

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm in the early stages of building out a database with Fluent NHibernate. I implemented a unit-of-work pattern in ASP.NET MVC 3 to let NHibernate update my database schema for me. To insert/update my initial data, I have a Database controller with an Update action that tries to SaveOrUpdate(...) a User entity (the administrator user) into the Users table. After manually deleting all user records via Visual Studio and re-running my Update action to repopulate the Users table, I receive the following NHibernate.StaleObjectStateException

Fluent NHibernate inheritance mapping problem

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Fluent NHibernate with table per subclass inheritance mapping. I want to reference to a list of specific objects, but i can't figure out, how to restict the result to objects of one specific class. class PetMap : ClassMap<Pet> { public PetMap() { Id(c => c.ID).GeneratedBy.Identity(); } } class DogMap : ClassMap<Dog> { public DogMap() { Mac(c => c.DogSpecificProperty); } } class CatMap : SubclassMap<Cat> { public CatMap() { Mac(c => c.CatSpecificProperty); } } class PersonMap : ClassMap<Person> { public PersonMap() { Id(c => c.ID)

Fluent NHibernate - Configure Oracle Data Provider ODP

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am brand new to NHibernate and Fluent NHibernate and I am trying to get the following confguration to work. private static ISessionFactory CreateSessionFactory () { return Fluently . Configure () . Database ( OracleDataClientConfiguration . Oracle10 . ConnectionString ( "Data Source=mysource;User ID=myid;Password=mypwd;" ) ) . Mappings ( m => m . FluentMappings . AddFromAssemblyOf < Program >()) . BuildSessionFactory (); } I have the Oracle.DataAccess assembly referenced. I am using VS 2010 and .Net 4 I get the following

Fluent NHibernate ― Saving Entity with Composite Key

匿名 (未验证) 提交于 2019-12-03 08:39:56
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: First, I have the following table: CREATE TABLE CustomerHub ( CustomerId INT NOT NULL , HubId INT NOT NULL ) Which I have mapped to the this entity: public class CustomerHub { public int CustomerId { get ; set ;} public int HubId { get ; set } //GetHashCode, Equals, Etc... } Using this mapping: public class CustomerHubMap : ClassMap < CustomerHub > { UseCompositeId () . WithKeyProperty ( x => x . CustomerId ) . WithKeyProperty ( x => x . HubId ); } The problem I have is that when I create a new entity of type CustomerHub and

Fluent Nhibernate Composite Key Not Generating Joins For Referenced Entities

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a mapping with a composite key as below: CompositeId () . KeyReference ( x => x . CreatedBy , "member_key" ) . KeyReference ( x => x . Box , "box_key" ); This works fine for simple gets and inserts, however it is not generating joins with the tables mentioned in the reference where I try and use them as part of a query. So this: return _sessionFactory . GetCurrentSession (). QueryOver < BoxMember >() . Where ( x => x . Box . Id == boxId ) . Where ( x => x . Member . DeletedDate == null ) . Fetch ( x => x . Box ). Eager .