fluent

How to Design Fluent Async Operations?

情到浓时终转凉″ 提交于 2019-12-04 18:38:59
问题 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. 回答1: Some of the answers that deal with continuations are

truncate all tables in laravel using eloquent

纵然是瞬间 提交于 2019-12-04 16:47:02
问题 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: 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 ==

EF Fluent API tutorial [closed]

别来无恙 提交于 2019-12-04 16:46:52
I want to learn Entity framework 4.1 Fluent API. Can you please send me goos links ? The ADO.NET team blog has a lot of information on getting started. There's a good series of articles on the CTP5 release. Also try Entity Framework Design and the Data developer center . And then there's always Google 来源: https://stackoverflow.com/questions/5450057/ef-fluent-api-tutorial

Doing joins with Fluent in a Vapor application

≡放荡痞女 提交于 2019-12-04 15:39:24
I'm struggling to figure out how to join my two tables together using fluent. In essence I want to run this SQL command: SELECT p.name, o.amount, o.amount * p.amount total FROM "OrderPoints" o INNER JOIN "Points" p ON o.points_id = p.id WHERE order_id = 10831 I've got my two models setup like so: final class OrderPoint: Codable, PostgreSQLModel, Content, Migration { var id: Int? = nil var orderID: Order.ID var pointID: Point.ID var amount: Double = 0 var point: Parent<OrderPoint, Point> { return parent(\.pointID) } } final class Point: Codable, PostgreSQLModel, Content, Migration { var id: Int

Castle Windsor Fluent API: Define dependency explicitly

☆樱花仙子☆ 提交于 2019-12-04 15:33:30
Given the below configuration Container.Register(Component.For<A>().Named("foo")); Container.Register(Component.For<B>().Named("foobar")); Container.Register( AllTypes.Pick() .FromAssemblyNamed("MyAssembly") .If(t => t.Name.EndsWith("ABC")) .Configure(c => c.LifeStyle.Is(LifestyleType.Transient)) .WithService.Select(i => typeof(I)) ); Container.Register( AllTypes.Pick() .FromAssemblyNamed("MyAssembly") .If(t => t.Name.EndsWith("123")) .Configure(c => c.LifeStyle.Is(LifestyleType.Transient)) .WithService.Select(i => typeof(I)) ); If I know that the interface "I" exposes a property "P", and that

Fluent Nhibernate Composite Key Not Generating Joins For Referenced Entities

依然范特西╮ 提交于 2019-12-04 15:08:26
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 .Fetch(x => x.CreatedBy).Eager .List(); Generates the following SQL: SELECT this_.member_key as member1_5_0_,

Fluent NHibernate - HasManyToMany NHibernate.MappingException: Repeated column in mapping for collection

前提是你 提交于 2019-12-04 03:55:49
问题 I'm a NHibernate novice trying to configure an existing database with Fluent NHibernate. The problem is with a many-to-many mapping, in this example represented by libraries and books. I guess this should be really basic stuff, but 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. ---> NHibernate

NHibernate Fluent and named Queries

落爺英雄遲暮 提交于 2019-12-04 03:41:49
问题 I am using Nhibernate with fluent. Now I want to call some Stored procedure and use named Queries. I created some xml: <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping> <sql-query name="CleanAppendicesHierarchies"> exec intf_CleanUpAppendixHierarchy </sql-query> </hibernate-mapping> FluentConfiguration cfg = Fluently.Configure().Database(MsSqlConfiguration.MsSql2005.ConnectionString( c => c.Is(dbConnectionString)).ShowSql()) .Mappings(m => m.FluentMappings.AddFromAssembly

Generic 'TThis' for fluent classes

ⅰ亾dé卋堺 提交于 2019-12-03 17:07:18
问题 I'm constructing a fluent interface where I have a base class that contains the bulk of the fluent logic, and a derived class that add some specialized behavior. The problem I'm facing is the return type of the fluent methods in the base class when called from an instance of the derived type. After invoking a method of the base class, only methods of the base class remain available for further fluent invocations. Changing the order in which the methods are invoked will help it to compile, but

NHibernate taking a long time to run query

六眼飞鱼酱① 提交于 2019-12-03 16:20:54
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 being returned is paged (50 per query) although as far as i can tell, this shouldn't make any difference I