fluent

Fluent NHibernate - Map 2 tables to one class

匿名 (未验证) 提交于 2019-12-03 02:00:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a table structure something like this table Employees EmployeeID EmployeeLogin EmployeeCustID table Customers CustomerID CustomerName What i would like is to map the structure above to one single class named: Class Employee EmployeeID EmployeeLogin EmployeeName How do i do that with fluent nhibernate ? 回答1: I don't know if it is possible with fluent, but in xml you use the join element: simplified: See this post by Ayende 回答2: I agree with Frans above but if you're stuck with someone else's code and have to use the existing

Fluent NHibernate mapping to a SQL Server CHAR(10) ID column

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: New to both NHibernate and Fluent NHibernate and I'm trying to resolve a performance problem in some inherited code caused by a conversion of a CHAR(10) column to NVARCHAR . From SQL Profiler: exec sp_executesql N'select mytestclas0_.LinkId as LinkId45_, mytestclas0_.Href as Href45_, mytestclas0_.LinkActive as LinkActive45_ from MessageLinks mytestclas0_ where mytestclas0_.LinkId=@p0',N'@p0 nvarchar(4000)',@p0=N'BzE2T48HMF' You can see the ID coming in from NHibernate is cast as a NVARCHAR . Table definition: CREATE TABLE [dbo].[MyTable](

What is the difference between a fluent interface and the Builder pattern? [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: When would you use the Builder Pattern? [closed] 15 answers I'm very new to design patterns and am having trouble with the difference between fluent interfaces and the Builder pattern. I understand the concept of fluent interfaces. But the builder pattern is a little confusing. I cannot understand the use of a Director in the Builder pattern. Can I use the Builder pattern and Fluent Interface together? If so, then how should I do so with a Director and a concrete builder? My question is not about

Is there any library to represent SQL queries as objects in Java code? [closed]

这一生的挚爱 提交于 2019-12-02 19:24:36
I was wondering if there is any library that can be used to represent SQL queries as objects in Java. In the code I have plenty of static variables of type java.lang.String that are hand written SQL queries. I would be looking for library having a nice fluent API that allows me to represent the queries as objects rather than strings. Example: Query q = select("DATE", "QUOTE") .from("STOCKMARKET") .where(eq("CORP", "?")) .orderBy("DATE", DESC); Jequel looks pretty nifty: http://www.jequel.de/ It uses a fluent interface, so it's easy to read, almost like natural SQL (from the docs): SqlString

Entity Framework Code First Soft Delete Lazy Loading

匆匆过客 提交于 2019-12-02 12:57:42
问题 So I'm using Entity Framework Code First (so no .edmx) I have a base entity class with a bool IsEnabled to do soft delete's I am using repository pattern so all queries against the repository can be filtered out with IsEnabled. However any time I use the repository to get an MyType which is IsEnabled, Lazy Loading MyType.Items may mean that Items could be not enabled. Is there a way, perhaps with EF Fluent to describe how to do filtering on tables? Update: If I have a Dbset public class

Entity Framework Code First Soft Delete Lazy Loading

旧街凉风 提交于 2019-12-02 07:06:16
So I'm using Entity Framework Code First (so no .edmx) I have a base entity class with a bool IsEnabled to do soft delete's I am using repository pattern so all queries against the repository can be filtered out with IsEnabled. However any time I use the repository to get an MyType which is IsEnabled, Lazy Loading MyType.Items may mean that Items could be not enabled. Is there a way, perhaps with EF Fluent to describe how to do filtering on tables? Update: If I have a Dbset public class UnitOfWork : DbContext { private IDbSet<MyObj> _MyObj; public IDbSet<MyObj> MyObjs { get { return _MyObj ??

Laravel 4 - paginate ignore distinct in Fluent

人盡茶涼 提交于 2019-12-02 04:26:59
问题 I make fluent request with distinct and paginate. My problem is that the paginate request is execute before disinct request My Fluent request : $candidates = DB::table('candidates') ->select('candidates.*') ->distinct() ->join('candidate_region', 'candidates.id', '=', 'candidate_region.candidate_id') ->join('candidate_job', 'candidates.id', '=', 'candidate_job.candidate_id') ->whereIn('candidate_region.region_id', $inputs['region']) ->whereIn('candidate_job.job_id', $inputs['job']) ->where(

Java inherited Fluent method return type in multiple level hierarchies

天涯浪子 提交于 2019-12-02 01:36:49
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 BaseFoo<T, S> { abstract void internalFoo(); @Override public S foo() { internalFoo(); return (S)this; }

How to map composite-id with fluent nhibernate using an interface?

ぃ、小莉子 提交于 2019-12-01 22:37:42
I'm trying to switch out .hbm mappings to fluent mappings and have a problem with the mapping of composite-ids and the usage of Interfaces the Class looks as follows: public class ClassWithCompositeId { public virtual IKeyOne KeyOne { get; set; } public virtual IKeyTwo KeyTwo { get; set; } } our hbm mapping looks like this: <hibernate-mapping ...> <class name="ClassWithCompositeId" table="t_classwithcompositeid"> <composite-id> <key-many-to-one name="KeyOne" column="colkeyone" class="company.namespace.boSkillBase, BL_Stammdaten" /> <key-many-to-one name="KeyTwo" column="colkeytwo" class=

FreeSql (四)实体特性 Fluent Api

梦想的初衷 提交于 2019-12-01 14:16:49
FreeSql (四)实体特性 Fluent Api FreeSql 提供使用 1654948748, 在外部配置实体的数据库特性,Fluent Api 的方法命名与特性名保持一致,如下: fsql.CodeFirst .ConfigEntity<TestFluenttb1>(a => { a.Name("xxdkdkdk1").SelectFilter("a.Id22 > 0"); a.Property(b => b.Id).Name("Id22").IsIdentity(true); a.Property(b => b.name).DbType("varchar(100)").IsNullable(true); }) .ConfigEntity<TestFluenttb2>(a => { a.Name("xxdkdkdk2").SelectFilter("a.Idx > 0"); a.Property(b => b.Id).Name("Id22").IsIdentity(true); a.Property(b => b.name).DbType("varchar(100)").IsNullable(true); }); //以下为实体类 class TestFluenttb1 { public int Id { get; set; } public string name {