eager-loading

IRepository and Unit Of Work vs Eager Loading

江枫思渺然 提交于 2019-12-04 11:39:48
I know having a Unit Of Work is having an abstraction on top of an abstraction ( DbContext ) and surely that is an anti-pattern, or at least is not necessary. I have the following problem: I have a generic IRepository like so: public interface IGenericRepository<TEntity> where TEntity : class { IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = ""); TEntity GetByID(object id); void Insert(TEntity entity); void Delete(object id); void Delete(TEntity entityToDelete); void Update

Eager loading child and child-of-child collections in NHibernate

一个人想着一个人 提交于 2019-12-04 09:04:14
I've got a problem with NHibernate trying to load a small hierarchy of data. My domain model looks like: class GrandParent { int ID{get;set;} IList<Parent> Parents {get; set;} } class Parent { IList<Child> Children {get; set;} } class Child { } and I would like to eager load all parents and children for a given GrandParent. This Linq-to-NH query creates the correct SQL and loads the GrandParent as expected: (the example assumes the grandparent has 2 parents who each have 2 child objects - so 4 child objects in total). var linq = session.Linq<GrandParent>(); linq.Expand("Parents"); linq.Expand(

How to Determine if Rails Association is Eager Loaded?

落花浮王杯 提交于 2019-12-04 07:47:43
问题 Does anyone know a way to determine if a Rails association has been eager loaded? My situation: I have a result set where sometimes one of the associations is eager loaded, and sometimes it isn't. If it isn't eager-loaded, then I want to look up associations using ActiveRecord's find. If it is eager loaded, I want to use detect. For example, say that I have a "has_many" array of shipping_info objects in my item model. Then: If item is eager loaded, most efficient load is: item.shipping_infos

Eager loading with route model binding

核能气质少年 提交于 2019-12-04 07:39:40
I have a controller function like this public function show(NovelRequest $request, Novel $novel) { // load the chapters $novel->chapters; // return the detail view of a novel return view('novels.show', compact('novel')); } I receive a novel object because i m using route model binding. However, I'd like to load more than the chapters. Since it would cause many request if i now do something like $novel->chapters; $novel->bookmarks; ... I wondered if theres a way to load "multiple" relations when i already have the novel object. Usually i would to something like Novel::with('chapters',

Completing object with its relations and avoiding unnecessary queries in sqlalchemy

穿精又带淫゛_ 提交于 2019-12-04 06:29:16
I have some database structure; as most of it is irrelevant for us, i'll describe just some relevant pieces. Let's lake Item object as example: items_table = Table("invtypes", gdata_meta, Column("typeID", Integer, primary_key = True), Column("typeName", String, index=True), Column("marketGroupID", Integer, ForeignKey("invmarketgroups.marketGroupID")), Column("groupID", Integer, ForeignKey("invgroups.groupID"), index=True)) mapper(Item, items_table, properties = {"group" : relation(Group, backref = "items"), "_Item__attributes" : relation(Attribute, collection_class = attribute_mapped

How can I use Entity Framework on an object graph past a depth of 2 with MySQL Connector / NET?

六月ゝ 毕业季﹏ 提交于 2019-12-04 03:08:53
问题 Here is a confirmed bug report with Oracle: http://bugs.mysql.com/bug.php?id=67183 Situation When using an .Include chain inside of my repository, I noticed that I was getting strange results - mostly that the values queried that were being returned were from the wrong fields (name would end up in description for example - but in the database all the values are correct, they only show up wrong after the query). I changed the names so the relationships are more obvious, but the structure is

Trouble on eager loading “second degree” associated objects

无人久伴 提交于 2019-12-04 01:55:04
问题 I am running Ruby on Rails 3.1. I would like to eager loading "second degree" associated objects by applying some conditions, but I am in trouble. It seems that I already solved part of my issue by using: article_categories = article .categories .includes(:comments => [:category_relationships]) .where(:category_relationships => {:user_id => @current_user.id}) where involved classes are stated as the following: class Category < ActiveRecord::Base has_many :comment_relationships has_many

Disable all lazy loading or force eager loading for a LINQ context

China☆狼群 提交于 2019-12-03 23:41:43
I have a document generator which contains queries for about 200 items at the moment but will likely be upwards of 500 when complete. I've recently noticed that some of the mappings denote lazy loading. This presents a problem for the document generator as it needs access to all of these properties based on which document is being generated. While I am aware of the DataLoadOptions that can be specified to the context, this would result in me having to explicitly specify every column that could possibly be loaded. That is north of 1000 as it all of the data fetching takes place in one context.

How to eager load sibling data using LINQ to SQL?

房东的猫 提交于 2019-12-03 23:03:18
The goal is to issue the fewest queries to SQL Server using LINQ to SQL without using anonymous types. The return type for the method will need to be IList<Child1>. The relationships are as follows: Parent Child1 Child2 Grandchild1 Parent > Child1 is a one-to-many relationship Child1 > Grandchild1 is a one-to-n relationship (where n is zero to infinity) Parent > Child2 is a one-to-n relationship (where n is zero to infinity) I am able to eager load the Parent, Child1 and Grandchild1 data resulting in one query to SQL Server. This query with load options eager loads all of the data, except the

Laravel 4.1 Eager Loading Nested Relationships with Constraints

≡放荡痞女 提交于 2019-12-03 17:09:36
问题 I am trying to get Eager-Loading nested relationships, with constraints, to work. Everyone seems to be giving the same example of eager-loading nested relationships: $users = User::with('posts.comments')->get(); What I want to do instead is get all the the Users related to a post of a given id. But at the same time, I also want to get the comments associated with that post. In 4.1, I to achieve the latter, I could do: $comments = Comment::whereHas('post', function($query) { $query->whereId(1)