lazy-loading

NHibernate serializing lazy-loaded entities with WCF

夙愿已清 提交于 2019-12-07 21:26:14
问题 I'm trying to send NH entities through the wire using WCF. I've got a complex graph of lazy-loaded objects.. I tried to implement a custom DataContractSurrogate to force initialization when serializing. Here is the code : public class HibernateDataContractSurrogate : IDataContractSurrogate { public HibernateDataContractSurrogate() { } public Type GetDataContractType(Type type) { // Serialize proxies as the base type if (typeof(INHibernateProxy).IsAssignableFrom(type)) { type = type.GetType()

Eager loading include with using UseLazyLoadingProxies

别来无恙 提交于 2019-12-07 20:16:32
问题 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

AngularJS - Delaying filter until after loading AJAX calls

Deadly 提交于 2019-12-07 19:47:59
问题 I want to know how I can delay the filter functionality until after loading all the data through AJAX calls. I'm trying to filter through data, but I can't filter some of them since they're not loaded until the AJAX calls. Is there a way to either delay the filter functionality or disable and enable it after all data is loaded? Update The way that the data structure is set up is that I make an AJAX call and load a list of posts made by different users. Afterwards, I call two other AJAX calls

Download script with dynamic src using Angular

こ雲淡風輕ζ 提交于 2019-12-07 19:43:21
问题 Angular provides ways to dynamically load templates with dynamic names via ng-include. Inline JS and CSS in that partial will load fine, but there is not a good way to download scripts with dynamic urls. We needed to download scripts, relative to the path of the .html partial calling them. (i.e. we had a directory with a file to include, and wanted the .html file to declare the scripts etc. it needed itself). As opposed to this question, which is loading a script with a static src in a

JPA equivalent command to Hibernate.initialize

别等时光非礼了梦想. 提交于 2019-12-07 19:06:16
问题 I have a Lazy collection that I want to initialize at will in my service/controller. At this moment I can do: Hibernate.initialize( myEntity.getListOfThings() ); This command is hibernate dependent and does not make the implementation of JPA transparent. Is there a JPA elegant way of doing this? 回答1: No, there's no JPA equivalent. You can learn if the object is loaded and than use one of the two options, either accessing the properties while the object is still attached to persistence context

Lazy load in Web API Core 2.2

…衆ロ難τιáo~ 提交于 2019-12-07 17:09:12
问题 I am having issues with the lazy loading. I have the following dbcontext. public virtual DbSet<AccountGroupMst> AccountGroupMst {get; set;} I have enabled the lazy loading. services.AddDbContext<DBContext>(x => x.UseSqlServer(Configuration.GetConnectionString("Test")) .UseLazyLoadingProxies()); Model, I have virtual and it is a self referencing table. public class AccountGroupMst { [Key] [Required] public int AccountGroupId { get; set; } [MaxLength(255)] [StringLength(255)] [Required] public

AngularJS, ocLazyLoad & loading dynamic States

房东的猫 提交于 2019-12-07 16:44:47
问题 app define(['angular', 'angular-ui-router', 'ocLazyLoad', 'config/common', 'layout/services/menuService'], function(angular) { 'use strict'; var $stateProviderRef = null; var $urlRouterProviderRef = null; return angular.module('app', ['ui.router', 'oc.lazyLoad', 'app.common', 'app.layout']); }); app.config define(['app'],function(app){ app.config(function($locationProvider, $stateProvider, $urlRouterProvider, $ocLazyLoadProvider) { $urlRouterProviderRef = $urlRouterProvider; $stateProviderRef

When asked to load a lazy field, Hibernate loads all lazy fields

久未见 提交于 2019-12-07 16:06:56
问题 I have a one2one relation between Student and Address . I want the firstName and lastName fields of Student to be lazy loaded. Also I want lazy for the address field. These are my entity classes: @Entity @Table(name = "students") public class Student { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @OneToOne(mappedBy = "student", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @LazyToOne(LazyToOneOption.NO_PROXY) private Address address; @Basic(fetch = FetchType

Store class definition in dictionary, instance later

半城伤御伤魂 提交于 2019-12-07 14:13:45
问题 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

Spring and Hibernate, Lazy initiation problem

做~自己de王妃 提交于 2019-12-07 12:29:48
问题 Hey I am developing an desktop application using Spring and Hibernate, and I have a problem with lazy initiation. I looked in the web and every solution is related to the open session in view pattern, but I can't use this pattern. I've also tried to get the sessionfactory from the HibernateTemplate , but it returns to me a disconnected session. Does anyone know other solution? 回答1: I would suggest that you basically have two solutions: Make arrangements to keep a Hibernate session open when