Ejemplo n.º 1
0
                private bool HasDeferredLoader(MetaDataMember deferredMember)
                {
                    if (!deferredMember.IsDeferred)
                    {
                        return(false);
                    }

                    MetaAccessor acc = deferredMember.StorageAccessor;

                    if (acc.HasAssignedValue(this.current) || acc.HasLoadedValue(this.current))
                    {
                        return(false);
                    }
                    MetaAccessor dsacc  = deferredMember.DeferredSourceAccessor;
                    IEnumerable  loader = (IEnumerable)dsacc.GetBoxedValue(this.current);

                    return(loader != null);
                }
Ejemplo n.º 2
0
                private void InitializeDeferredLoader(MetaDataMember deferredMember)
                {
                    MetaAccessor storageAccessor = deferredMember.StorageAccessor;

                    if (!storageAccessor.HasAssignedValue(current) && !storageAccessor.HasLoadedValue(current))
                    {
                        var deferredSourceAccessor = deferredMember.DeferredSourceAccessor;
                        var boxedValue             = (IEnumerable)deferredSourceAccessor.GetBoxedValue(current);
                        if (boxedValue == null)
                        {
                            boxedValue = tracker.services.GetDeferredSourceFactory(deferredMember)
                                         .CreateDeferredSource(current);
                            deferredSourceAccessor.SetBoxedValue(ref current, boxedValue);
                        }
                        else if (!haveInitializedDeferredLoaders)
                        {
                            throw Error.CannotAttachAddNonNewEntities();
                        }
                    }
                }
Ejemplo n.º 3
0
                private bool HasDeferredLoader(MetaDataMember deferredMember)
                {
                    if (!deferredMember.IsDeferred)
                    {
                        return(false);
                    }
                    MetaAccessor storageAccessor = deferredMember.StorageAccessor;

                    if (storageAccessor.HasAssignedValue(current) || storageAccessor.HasLoadedValue(current))
                    {
                        return(false);
                    }
                    var boxedValue =
                        (IEnumerable)deferredMember.DeferredSourceAccessor.GetBoxedValue(current);

#if DEBUG
                    boxedValue = (IEnumerable)deferredMember.DeferredSourceAccessor.GetBoxedValue(current);
#endif
                    return(boxedValue != null);
                }
Ejemplo n.º 4
0
                private void InitializeDeferredLoader(MetaDataMember deferredMember)
                {
                    MetaAccessor acc = deferredMember.StorageAccessor;

                    if (!acc.HasAssignedValue(this.current) && !acc.HasLoadedValue(this.current))
                    {
                        MetaAccessor dsacc  = deferredMember.DeferredSourceAccessor;
                        IEnumerable  loader = (IEnumerable)dsacc.GetBoxedValue(this.current);
                        // don't reset loader on any deferred member that already has one
                        if (loader == null)
                        {
                            IDeferredSourceFactory factory = this.tracker.services.GetDeferredSourceFactory(deferredMember);
                            loader = factory.CreateDeferredSource(this.current);
                            dsacc.SetBoxedValue(ref this.current, loader);
                        }
                        else if (loader != null && !haveInitializedDeferredLoaders)
                        {
                            // If loader is present but wasn't generated by us, then
                            // an attempt to Attach or Add an entity from another context
                            // has been made, which is not supported.
                            throw Error.CannotAttachAddNonNewEntities();
                        }
                    }
                }