I have the following models:
class Person < ActiveRecord::Base
has_many :images
has_one :preference
end
class Image < ActiveRecord::Base
belongs_to :person
end
class Preference < ActiveRecord::Base
belongs_to :person
end
I am trying to fetch all images that are public and at the same time eager load the people who own those imag...
I'm currently learning a bit more about Linq-To-Entities - particularly at the moment about eager and lazy loading.
proxy.User.Include("Role").First(u => u.UserId == userId)
This is supposed to load the User, along with any roles that user has. I have a problem, but I also have a question. It's just a simple model created to learn a...
I'm wondering how to properly handle eager-loading problem for complex object graphs when using Repository pattern. This isn't ORM specific problem i guess.
First try:
public interface IProductRepository : IRepository<Product>
{
Product GetById(int id);
IProductRepository WithCustomers();
}
This would work fine, but that would in...
Here's a bunch of things I tried... hopefully you can extrapolate from it what I'm trying to do and what I'm doing wrong. Okay so I'm having problems with loading related entities when using this DoQuery:
public ObjectQuery<E> DoQuery(ISpecification<E> where)
{
return (ObjectQuery<E>)_ctx.CreateQuery<E>("[" + typeof(E).Nam...
I understand in Entity Framework you can specify relationships that need to be joined with Include:
Product firstProduct =
db.Product.Include("OrderDetail").Include("Supplier").First();
But we have the opposite issue that a simple LINQ statement is getting making too many JOINs on the SQL server.
So how do we do the opposite...
Lets say I have 3 tables Posts, PostTags and Tags defining a many-to-many relationship. I want to get a lookup table that will give me all the Posts related to a given tag so I use the following code:
return dataContext.PostTags.ToLookup(pt => pt.Tag, pt => pt.Post);
In unit test all went fine but in the real application, it didn't wo...
Hi folks,
I have a very simple repository I'm playing around with, using Entity Framework v4 that comes with VS2010 Beta 2.
I'm trying to dynamically include the Include method, if a user optionally asks for it.
eg.
Public IQueryable<Foo> GetFoos(bool includeBars)
{
var entites = new Entities("... connection string ... ");
v...
I have an element bound to an entity (Contact) that exposes some navigation properties.
I want, that on some action (i.e. a "Load children" button), the Contact should load for all its children and grand children like I can do with an ObjectQuery.Include before the execution; example (pseudo):
DirectCast(element.DataContext, Contact).S...
Grails 1.1.1
Goovy 1.5.7
In a relationship such this:
Author 1 -- n Book n -- 1 Publisher
Defined in Grails:
class Author {
String firstName
String lastName
static hasMany = [books: Book]
static constraints = {
books(nullable: true)
}
}
class Book {
String title
Author author
Publisher ...
I have a situation where children are built but not saved, and are then being used in the view with references to the parent. This leads to extensive use of rails record caching. I'd like to have the parent 'eager loaded' with the unsaved children records.
class Parent < ActiveRecord::Base
has_many :children
def make_children
lo...
Hello!
I have a linq-to-sql data layer, with 2 tables in it. "Parent" and "Child". There's a relationship between Child and Parent (so parent has many children, etc etc), a parent can also have many parents (when children grow up and themselves become parents).
I want to display this hierarchy out to the user, but I'm not sure how to...
I've been working on an API (which wraps a web-service of sorts) for a while now, and its just about feature complete.
I initially designed this API to be lazy/delay-loaded throughout; which makes perfect sense if you're only interested in a small subset of the available data given the latency inherent in consuming a web-service. Howev...
I have a number of custom find_by_sql queries in Rails. I would like to use eager loading with them but there doesn't seem to be a good way to do this.
I have seen the eager_custom.rb file floating around and it doesn't seem to work with Rails now. It appear Rails does eager loading differently now, using 2 queries (the regular query ...
I've got a situation where I need to prefetch some entities through a many-to-many relationship. So it's like the classic BlogPost <- BlogPostTag -> Tag situation.
Yes, I'm aware of LoadOptions but I can't use it because it's a web application and I'm using the one datacontext per request pattern.
It also seems you can't use projection...
I have a generic repository and when I'm using a DoQuery method to select objects from the database, I need to load some of the related entities in order to not get nulls in the place of the fields that are foreign keys.
The problem is that the repository is generic, so I do not know how many properties need loading or what their names ...
I have an object that has many assocations to other objects. All of these are fetched lazily by nHibernate, which is good in almost all cases.
In a particular scenario, in this case an export of a lot of records, I want to set the Fetchmode to eager on all associations. Is there a way to do this, without having to manually specify each...
In a Rails 2.3.5 application I've got something like the following models:
class Foo < ActiveRecord::Base
has_many :bars
end
class Bar < ActiveRecord::Base
belongs_to :foo
end
And when I'm calling
Foo.all(:include => :bars)
I see the following queries in console:
SELECT * FROM "foos"
SELECT "bars".* FROM "bars" WHERE ("bars...
OK, I've been playing around with some of the eager loading things, and have 2 models something like:
Class Recipe < ActiveRecord::Base
belongs_to :cookbook
has_many :recipetags
end
and
Class Cookbook < ActiveRecord::Base
has_many :recipes, :include => [:recipetags]
end
Which is working out well, when I find a Cookboo...
I have two models in relation one-to-many:
class Question(db.Model):
questionText = db.StringProperty(multiline=False)
class Answer(db.Model):
answerText = db.StringProperty(multiline=False)
question = db.ReferenceProperty(Question, collection_name='answers')
I have front-end implemented in F...
I'm using Eager Loading to bring back 2 types of entities that I later want to put into IEnumberables of the respective types to do work with.
crocodileEntities proxy = new crocodileEntities(new Uri("CrocodileDbDataService.svc", UriKind.Relative));
var ProjectionsQuery = from OptionARMRuns in proxy.OptionARMRuns.Expand("OptionARMRunI...