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); }
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(); } } }
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); }
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(); } } }
private void AutoSyncMembers(object[] syncResults, TrackedObject item, UpdateType updateType, AutoSyncBehavior autoSyncBehavior) { System.Diagnostics.Debug.Assert(item != null); System.Diagnostics.Debug.Assert(item.IsNew || item.IsPossiblyModified, "AutoSyncMembers should only be called for new and modified objects."); object[] syncRollbackValues = null; if (syncResults != null) { int idx = 0; var membersToSync = GetAutoSyncMembers(item.Type, updateType); System.Diagnostics.Debug.Assert(syncResults.Length == membersToSync.Count); if (autoSyncBehavior == AutoSyncBehavior.ApplyNewAutoSync) { syncRollbackValues = new object[syncResults.Length]; } foreach (MetaDataMember mm in membersToSync) { object value = syncResults[idx]; object current = item.Current; MetaAccessor accessor = (mm.Member is PropertyInfo && ((PropertyInfo)mm.Member).CanWrite) ? mm.MemberAccessor : mm.StorageAccessor; if (syncRollbackValues != null) { syncRollbackValues[idx] = accessor.GetBoxedValue(current); } accessor.SetBoxedValue(ref current, DBConvert.ChangeType(value, mm.Type)); idx++; } } if (syncRollbackValues != null) { this.SyncRollbackItems.Add(new KeyValuePair <TrackedObject, object[]>(item, syncRollbackValues)); } }
internal MultiKeyManager(MetaAccessor <T, V1> accessor, int offset, KeyManager <T, V2> next) { this.accessor = accessor; this.next = next; this.offset = offset; }
internal SingleKeyManager(MetaAccessor <T, V> accessor, int offset) { this.accessor = accessor; this.offset = offset; isKeyNullAssignable = TypeSystem.IsNullAssignable(typeof(V)); }
internal SingleKeyManager(MetaAccessor <T, V> accessor, int offset) { this.accessor = accessor; this.offset = offset; this.isKeyNullAssignable = System.Data.Linq.SqlClient.TypeSystem.IsNullAssignable(typeof(V)); }
// Methods internal MultiKeyManager(MetaAccessor <T, V1> accessor, int offset, IdentityManager.StandardIdentityManager.KeyManager <T, V2> next) { this.accessor = accessor; this.next = next; this.offset = offset; }