public void Attach_IDataObject_Existing_Twice() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = new TestObjClassEfImpl(null) { ID = 3, ClientObjectState = DataObjectState.Unmodified }; Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Detached)); ctx.Attach(obj); Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Unchanged)); ctx.Attach(obj); Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Unchanged)); } }
protected ValueCollectionWrapper(IZetboxContext ctx, TParent parent, Action parentNotifier, TEntryCollection collection) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (parent == null) { throw new ArgumentNullException("parent"); } // may be null: if (parentNotifier == null) { throw new ArgumentNullException("parentNotifier"); } if (collection == null) { throw new ArgumentNullException("collection"); } this.ctx = ctx; this.parent = parent; this.parentNotifier = parentNotifier; this.collection = collection; this.tEntryImplementation = ctx.GetImplementationType(typeof(TEntry)); this.tEntryInterface = tEntryImplementation.ToInterfaceType(); // may be necessary on (lazy) initialisation foreach (var item in this.collection) { if (item.Context != this.ctx) { ctx.Attach(item); } } }
protected virtual TEntry InitialiseEntry(TEntry e, TValue value) { e.UpdateParent("Parent", parent); e.Value = value; ctx.Attach(e); return(e); }
public override void AttachToContext(IZetboxContext ctx) { base.AttachToContext(ctx); if (_PhoneNumbersOtherCollection != null) { _PhoneNumbersOtherCollection.ForEach <IPersistenceObject>(i => ctx.Attach(i)); } }
public override void SetUp() { base.SetUp(); _iftFactory = scope.Resolve <InterfaceType.Factory>(); ctx = GetContext(); obj = new TestObjClassImpl(); ctx.Attach(obj); }
public override void AttachToContext(IZetboxContext ctx) { base.AttachToContext(ctx); if (ctx.ContainsObject(ctx.GetInterfaceType(this), this.ID) == null) { // Object is not in this Context present // -> Attach it. Attach will call this Method again! ctx.Attach(this); } }
public void AttachedObjects() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = new TestObjClassEfImpl(null); ctx.Attach(obj); ctx.Create <TestObjClass>(); Assert.That(ctx.AttachedObjects.Count(), Is.EqualTo(2)); } }
public void ContainsObject() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = new TestObjClassEfImpl(null) { ID = 10 }; ctx.Attach(obj); ctx.Create <TestObjClass>(); Assert.That(ctx.AttachedObjects.Count(), Is.EqualTo(2)); Assert.That(ctx.ContainsObject(ctx.GetInterfaceType(obj), obj.ID), Is.EqualTo(obj)); } }
public void DetachFromContext() { Assert.That(obj.Context, Is.Null); obj.SetPrivatePropertyValue <int>("ID", 10); using (IZetboxContext ctx = GetContext()) { ctx.Attach(obj); Assert.That(obj.Context, Is.Not.Null); obj.DetachFromContext(ctx); Assert.That(obj.Context, Is.Null); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified)); Assert.That(PropertyChangedCalled, Is.True); } }
public void InitialiseObject(IZetboxContext ctx, ObjectClass obj) { ctx.Attach(obj); obj.BaseObjectClass = null; obj.Name = "testclassname"; obj.DefaultIcon = null; obj.Description = "testclassdescription"; obj.ImplementsInterfaces.Clear(); obj.IsFrozenObject = false; obj.IsSimpleObject = false; obj.Methods.Clear(); obj.Module = ctx.GetQuery <Zetbox.App.Base.Module>().First(); obj.Properties.Clear(); obj.SubClasses.Clear(); obj.TableName = "testtablename"; }
public void FromStream_creates_correct_Object() { var typeMap = scope.Resolve <TypeMap>(); var ms = new MemoryStream(); var sw = new ZetboxStreamWriter(typeMap, new BinaryWriter(ms)); var sr = new ZetboxStreamReader(typeMap, new BinaryReader(ms)); TestObjClassSerializationMock.ToStream <TestObjClass, TestEnum>(sw, _iftFactory); sw.Flush(); Assert.That(ms.Length, Is.GreaterThan(0)); ms.Seek(0, SeekOrigin.Begin); var t = sr.ReadSerializableType(); Assert.That(t.GetSystemType().IsAssignableFrom(typeof(TestObjClass)), string.Format("{0} not assignable to {1}", typeof(TestObjClass), t)); var obj = new TestObjClassImpl(); obj.FromStream(sr); ctx.Attach(obj); TestObjClassSerializationMock.AssertCorrectContentsEnum <TestObjClass>(obj); }
public override void SetUp() { base.SetUp(); _iftFactory = scope.Resolve<InterfaceType.Factory>(); ctx = GetContext(); obj = new TestObjClassImpl(); ctx.Attach(obj); }
public void AttachToContext(IZetboxContext ctx) { OnCollectionResetting(); collection = new List <T>(collection.Select(i => ctx.Attach(i)).Cast <T>()); OnCollectionReset(); }
public override void AttachToContext(IZetboxContext ctx, Func<IFrozenContext> lazyFrozenContext) { base.AttachToContext(ctx, lazyFrozenContext); if (ctx.ContainsObject(ctx.GetInterfaceType(this), this.ID) == null) { // Object is not in this Context present // -> Attach it. Attach will call this Method again! ctx.Attach(this); } }
public void Attach_IDataObject_Null() { ctx.Attach((IDataObject)null); }
public override void AttachToContext(IZetboxContext ctx) { base.AttachToContext(ctx); if (_PhoneNumbersOther != null) PhoneNumbersOtherImpl.ForEach<IPersistenceObject>(i => ctx.Attach(i)); }
public override void SetUp() { base.SetUp(); ctx = GetContext(); ctx.Attach(obj); }
public override void AttachToContext(IZetboxContext ctx) { base.AttachToContext(ctx); if (_EMails != null) EMailsImpl.ForEach<IPersistenceObject>(i => ctx.Attach(i)); }