private static ISessionImplementor GetSessionFromCollection(IEnumerable collection, int depth, Func <object, int, bool> predicate, Func <Type, GetSessionDelegate> getTypeSessionGetter, Predicate <Type> isEntityPredicate) { return(GetSession(collection, out var isProxy) ?? (isProxy ? null : GetSessionFromCollection())); ISessionImplementor GetSessionFromCollection() { if (!predicate(collection, depth) || collection == null) { return(null); } depth++; // Non generic collection foreach (var item in collection) { var type = BreezeHelper.GetEntityType(item, false); if (isEntityPredicate(type)) { continue; } var session = GetSessionFromEntity(item, depth, predicate, getTypeSessionGetter); if (session != null) { return(session); } } return(null); } }
private void InitializeObject(object item, ExpandNode expandNode) { if (item is INHibernateProxy nhProxy) { nhProxy.HibernateLazyInitializer.Initialize(); item = nhProxy.HibernateLazyInitializer.GetImplementation(); } var metadata = _typeExpandMetadata.GetOrAdd(BreezeHelper.GetEntityType(item), CreateExpandMetadata); foreach (var expand in expandNode.Expands.Values) { Initialize(metadata.GetPropertyValue(expand.PropertyName, item), expand); } }
private static ISessionImplementor GetSessionFromEntity( object value, int depth, Func <object, int, bool> predicate, Func <Type, GetSessionDelegate> getTypeSessionGetter) { return(GetSession(value, out var isProxy) ?? (isProxy ? null : GetSessionFromEntityRecursive())); ISessionImplementor GetSessionFromEntityRecursive() { if (!predicate(value, depth) || value == null) { return(null); } var sessionGetter = getTypeSessionGetter(BreezeHelper.GetEntityType(value, false)); return(sessionGetter.Invoke(value, depth + 1, predicate)); } }