eager-loading

Getting specific columns with eager loading laravel 4

穿精又带淫゛_ 提交于 2019-11-26 21:04:56
问题 I am new to laravel and making a basic application to get a grip on relationships.I have implemented one to one relationship and want to get specific columns from both the base table and the related table.I have two tables namely users and identity_cards.Relationship is defined as follows class User extends Eloquent implements UserInterface, RemindableInterface { use UserTrait, RemindableTrait; /** * The database table used by the model. * * @var string */ protected $table = 'users'; /** *

EF4 LINQ Ordering Parent and all child collections with Eager Loading (.Include())

我只是一个虾纸丫 提交于 2019-11-26 16:38:23
问题 I am doing hierarchical data binding on a grid, and I need to have the database server perform the sorting on my objects. I can easily sort the parent collection, but I can't seem to figure out how to also sort all the child collections. I have a model which has child collections nested 3 deep, and all of these collections need to be sorted. Here is a sample model of what I'm trying to accomplish: public class Year { public int Id { get; set; } public string Name { get; set; } public List

org.hibernate.LazyInitializationException at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel

百般思念 提交于 2019-11-26 14:08:14
问题 Despite of FetchType.EAGER and JOIN FETCH , I get a LazyInitalizationException while adding some objects to a @ManyToMany collection via a JSF UISelectMany component such as in my case the <p:selectManyMenu> . The @Entity IdentUser , with FetchType.EAGER : @Column(name = "EMPLOYERS") @ManyToMany(fetch = FetchType.EAGER, cascade= CascadeType.ALL) @JoinTable(name = "USER_COMPANY", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "COMPANY_ID") }) private

Fighting cartesian product (x-join) when using NHibernate 3.0.0

谁都会走 提交于 2019-11-26 12:50:53
I'm bad at math but I kind get idea what cartesian product is. Here is my situation (simplified): public class Project{ public IList<Partner> Partners{get;set;} } public class Partner{ public IList<PartnerCosts> Costs{get;set;} public IList<Address> Addresses{get;set;} } public class PartnerCosts{ public Money Total{get;set;} } public class Money{ public decimal Amount{get;set;} public int CurrencyCode{get;set;} } public class Address{ public string Street{get;set;} } My aim is to effectively load entire Project. Problem of course is: If I try to eager load partners and their costs, query

Entity Framework 4.1 default eager loading

女生的网名这么多〃 提交于 2019-11-26 12:44:29
问题 I\'m using Entity Framework 4.1 code first approach. I want to make eager loading as my the dafault configuration, and by that avoid using the Include extension method in each fetching query. I did as recomended in MSDN, changing the simple lazy property at the DbContext constructor: public class EMarketContext : DbContext { public EMarketContext() { // Change the default lazy loading to eager loading this.Configuration.LazyLoadingEnabled = false; } } unfortunately, this approach is not

Eloquent eager load Order by

最后都变了- 提交于 2019-11-26 09:22:54
问题 I have problem with eloquent query. I am using eager loading (one to one Relationship) to get \' student \' With the \' exam \', Using the code below. Student::with(\'exam\')->orderBy(\'exam.result\', \'DESC\')->get() And i want to order received rows by the \' result \' column in \' exam \'. I am using ->orderBy(\'exam.result\', \'DESC\') But it is not working. Any ideas how to do it ? 回答1: Try this: Student::with(array('exam' => function($query) { $query->orderBy('result', 'DESC'); })) -

Entity Framework Core 2.0.1 Eager Loading on all nested related entities

梦想与她 提交于 2019-11-26 07:42:20
问题 I have a simple problem, but cant seem to find a way around it. I am using Entity Framework Core version 2.0.1 and want to eager load all my entities by default. Example: public class Order { public int Id { get; set; } public string Name { get; set; } public int CustomerId { get; set; } public Customer Customer { get; set; } } public class Customer { public int Id { get; set; } public string Name { get; set; } public int AddressId { get; set; } public Address Address { get; set; } } public

Fighting cartesian product (x-join) when using NHibernate 3.0.0

我与影子孤独终老i 提交于 2019-11-26 03:07:37
问题 I\'m bad at math but I kind get idea what cartesian product is. Here is my situation (simplified): public class Project{ public IList<Partner> Partners{get;set;} } public class Partner{ public IList<PartnerCosts> Costs{get;set;} public IList<Address> Addresses{get;set;} } public class PartnerCosts{ public Money Total{get;set;} } public class Money{ public decimal Amount{get;set;} public int CurrencyCode{get;set;} } public class Address{ public string Street{get;set;} } My aim is to

How to Eager Load Associations without duplication in NHibernate?

感情迁移 提交于 2019-11-26 00:08:33
问题 I\'d need to load a list of very large objects with so many children and children of children. what\'s the best approach to take? I\'m using Oracle 11g database and I\'ve written the below method but it results in cartesian product (duplicated results): public IList<ARNomination> GetByEventId(long eventId) { var session = this._sessionFactory.Session; var nominationQuery = session.Query<ARNomination>().Where(n => n.Event.Id == eventId); using (var trans = session.Transaction) { trans.Begin();