lazy-loading

How to lazy load?

只愿长相守 提交于 2019-12-06 07:50:16
How do you lazy load a NSMutableArray in tableView:didSelectRowAtIndexPath: ? I am very new to Objective-C, XCode, and iOS programming, so any help is appreciated. Lazy load means 'loading on demand'. So you perform operation only when it is really necessary, and not beforehand. Say we have method: -(void) init { self = [super init]; mMyMemberArray = [self loadSomeDataToArray]; } -(void) tableView:didSelectRowAtIndexPath: { [someObject processData: mMyMemberArray]; } This is not lazy loading cause we've loaded data beforehand. But this: -(void) tableView:didSelectRowAtIndexPath: { someObject

Eager loading include with using UseLazyLoadingProxies

寵の児 提交于 2019-12-06 07:20:13
I am creating the db connection like so: protected override void OnConfiguring(DbContextOptionsBuilder optionbuilder) { optionbuilder.UseLazyLoadingProxies().UseSqlite(@"Data Source=Data.db"); } And I am trying to access an object like so: public static User GetProfile(int uid) { using (Db db = new Db()) { return db.Users.Include(x => x.Settings).FirstOrDefault(x => x.UserId == uid); } } The user object is as follows: public class User { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string Name { get; set; } public DateTime? LastUsed{ get;

Hibernate ignores 'lazy' fetch type and loads properties immediately

时光总嘲笑我的痴心妄想 提交于 2019-12-06 07:14:11
问题 I use Hibernate 5.2.5 (also use kotlin and spring 4.3.5 if that matters) and I want some of the fields of my class to be loaded lazily. But the issue is that all fields are loaded immediately, I don't have any special Hibernate settings neither use Hibernate.initialize(). @Entity(name = "task") @Table(name = "tasks") @NamedQueries( NamedQuery(name = "task.findById", query = "SELECT t FROM task AS t WHERE t.id = :id") ) class Task { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var

Entity Framework and Object Context lifetime in ASP.NET MVC

本秂侑毒 提交于 2019-12-06 05:14:57
问题 I'm using Entity Framework in my project, and I have the problem that, once I pass my entities to a View (keep in mind that these entities have lazy-initialized objects along the lines of: Products.Owner, where owner is an object that is lazily initialized) I get a run-time exception telling me that the ObjectContext is out of scope. Now this makes sense since I am getting the entities from a Service with a using (.... entities...) { .... } statement, which means it is disposed when the

How to fix a NHibernate lazy loading error “no session or session was closed”?

廉价感情. 提交于 2019-12-06 04:54:43
问题 I'm developing a website with ASP.NET MVC, NHibernate and Fluent Hibernate and getting the error " no session or session was closed " when I try to access a child object. These are my domain classes: public class ImageGallery { public virtual int Id { get; set; } public virtual string Title { get; set; } public virtual IList<Image> Images { get; set; } } public class Image { public virtual int Id { get; set; } public virtual ImageGallery ImageGallery { get; set; } public virtual string File {

How significant are JPA lazy loading performance benefits?

可紊 提交于 2019-12-06 04:23:34
I understand that this is highly specific to the concrete application, but I'm just wondering what's the general opinion, or at least some personal experiences on the issue. I have an aversion towards the 'open session in view' pattern, so to avoid it, I'm thinking about simply fetching everything small eagerly, and using queries in the service layer to fetch larger stuff. Has anyone used this and regretted it? And is there maybe some elegant solution to lazy loading in the view layer that I'm not aware of? Lazy loading is only beneficial if you aren't going to use the data in question at all

Store class definition in dictionary, instance later

时间秒杀一切 提交于 2019-12-06 03:43:04
What I want to do is something like the following (All object class have a common interface): MyDict.Add("A", MyAObjectClass); // Not an instance MyDict.Add("B", MyBObjectClass); MyDict.Add("C", MyCOjbectClass); String typeIwant = "B"; // Could be passed to a function or something MyCommonInterface myobject = MyDict[typeIwant](); How could I program something like this? The purpose of this is to not have to create instances of every single type I will store in my dictionary (could be quite a bit of them) and instead only instance the one I'm actually going to use. You can store type

How to conditionally assign ActionController::Base.session in rails 2.3.3

烈酒焚心 提交于 2019-12-06 03:32:18
问题 I have a rails app that has the following content in the config/initializers/session_store.rb file: ActionController::Base.session = { :key => '_app_session', :secret => 'a really long string here', :expire_after => 2.minutes } ActionController::Base.session_store = :active_record_store So during normal operations we are seeing ActiveRecord objects created in the database for each session. The issue is that we don't always want to create a session for requests - we'd like to be able to turn

Deep understanding of lazy loading and disposing error in MVC .net

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 02:41:44
问题 i was trying to write a full detailed answer to the following question: Why does "Dispose" work, and not "using(var db = new DataContext())"? so I set up my project that include: Departments and employees using entity framework so my action method was this: public ActionResult Index() { IEnumerable<department> d; using (var ctx = new ApplicationDbContext()) { d = ctx.departments; } return View(d); } it is natural to expect that this will result in the common error : The operation cannot be

DataTable - Lazy Loading Primefaces showing error

二次信任 提交于 2019-12-06 02:34:20
问题 I am using JSF2.0 with PrimeFaces3.1 and Spring3.1 for Business logic.I was trying to use a DataTable- Lazy loading. But It is giving me the following error. Kindly help. An Error Occurred: / by zero - Stack Trace java.lang.ArithmeticException: / by zero at org.primefaces.model.LazyDataModel.setRowIndex(LazyDataModel.java:62) at javax.faces.component.UIData.setRowIndex(UIData.java:448) at javax.faces.component.UIData.visitColumnsAndRows(UIData.java:1544) at javax.faces.component.UIData