we have something at unhaddins: http://code.google.com/p/unhaddins/source/browse/#svn/sandbox/RemoteLazy http://code.google.com/p/unhaddins/source/browse/#svn/sandbox/WCFLazyLoad
yes we use a contract serializer. I'm serializing a custom proxy reference (entity type + id). Then in the other side of the cable, we create a new "proxy", that works like the nh proxy but it resolve itself through a common wcf service. have a look 2010/2/2 [email protected] <[email protected]> > What you need is a data contract serializer to push data across the > pipe (the example below is only for outgoing). If it see's an > uninitialized proxy, it will skip serialization on it. > > using System; > using System.CodeDom; > using System.Reflection; > using System.Runtime.Serialization; > using System.Collections.ObjectModel; > using log4net; > using NHibernate.Proxy; > > namespace MyNamespace.ServiceModel { > public class NhDataContractSurrogate : IDataContractSurrogate { > private static readonly ILog log = LogManager.GetLogger(typeof > (NhDataContractSurrogate)); > > #region IDataContractSurrogate Members > public object GetObjectToSerialize(object obj, Type > targetType) { > log.Debug("Checking object"); > var proxy = obj as INHibernateProxy; > if (proxy != null) { > log.Debug("Hibernate proxy found"); > var li = proxy.HibernateLazyInitializer; > if (li.IsUninitialized) { > log.Debug("Hibernate proxy is not initialized and > will not be serialized"); > obj = null; > } > else { > obj = li.GetImplementation(); > log.DebugFormat( > "Hibernate proxy was initialized and has been > casted to its implementation of type '{0}'", > obj.GetType().FullName > ); > } > } > return obj; > } > > public object GetCustomDataToExport(Type clrType, Type > dataContractType) { > return null; > } > > public object GetCustomDataToExport(MemberInfo memberInfo, > Type dataContractType) { > return null; > } > > public Type GetDataContractType(Type type) { > return type; > } > > public object GetDeserializedObject(object obj, Type > targetType) { > return obj; > } > > public void GetKnownCustomDataTypes(Collection<Type> > customDataTypes) { > } > > > public Type GetReferencedTypeOnImport(string typeName, string > typeNamespace, object customData) { > return null; > } > > public CodeTypeDeclaration ProcessImportedType > (CodeTypeDeclaration typeDeclaration, CodeCompileUnit compileUnit) { > return typeDeclaration; > } > > #endregion > } > } > > On Feb 2, 5:37 am, Peter Derwa <[email protected]> wrote: > > Hey, > > > > I've downloaded the new version of NHibernate and I found some > > comments about the possibilities to create your own custom lazy loader > > for the new NHibernate version. > > Now that looks great!!! we are using a WCF Service so we are currently > > working with lazy = false, and that kinda sucks big time, because when > > loading a complete table with lots of relations, that will consume > > quite allot of time. > > > > Could someone point me into a right direction of how to do that? I was > > not able to find the right article yet. > > One note to keep in mind, we have multiple projects aka databases, so > > in my lazy loading customization i'll have to be able to add that > > project ID to create a session to the right database! > > > > grt > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
