public void Test() { SubClass1 sc1 = new SubClass1(); sc1.Name = "obj1"; object savedId; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { savedId = s.Save(sc1); tx.Commit(); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Assert.IsNull(s.Get<SubClass2>(savedId)); tx.Commit(); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Load<SomeClass>(savedId); // Load a proxy by the parent class Assert.IsNull(s.Get<SubClass2>(savedId)); tx.Commit(); } }
public async Task TestAsync() { SubClass1 sc1 = new SubClass1(); sc1.Name = "obj1"; object savedId; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { savedId = await(s.SaveAsync(sc1)); await(tx.CommitAsync()); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Assert.IsNull(await(s.GetAsync <SubClass2>(savedId))); await(tx.CommitAsync()); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { await(s.LoadAsync <SomeClass>(savedId)); // Load a proxy by the parent class Assert.IsNull(await(s.GetAsync <SubClass2>(savedId))); await(tx.CommitAsync()); } }
public void Test() { SubClass1 sc1 = new SubClass1(); sc1.Name = "obj1"; object savedId; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { savedId = s.Save(sc1); tx.Commit(); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Assert.IsNull(s.Get <SubClass2>(savedId)); tx.Commit(); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Load <SomeClass>(savedId); // Load a proxy by the parent class Assert.IsNull(s.Get <SubClass2>(savedId)); tx.Commit(); } }
static void Virtual() { SubClass1 tamim = new SubClass1 { name = "Tamim", mortgage = 101 }; if (tamim is SubClass1 s && s.mortgage > 100) { WriteLine($"Name : {s.name} \nLibality : {s.Libility} Tk"); }
static void Main(string[] args) { IBase <string> instance1 = new SubClass1(); IBase <int> instance2 = new SubClass2(); instance1.SomeMethod(); //this should call SomeMethod<string>() instance2.SomeMethod(); //this should call SomeMethod<int>() Console.ReadLine(); }
public Class1() { var test = new SubClass1(); var lookup = new Dictionary <Type, Action <object> > { { typeof(SubClass1), o => ((SubClass1)o).SomeMethod1() }, { typeof(SubClass2), o => ((SubClass2)o).SomeMethod2() } }; lookup[test.GetType()](test); }
public Class1() { var test = new SubClass1(); var lookup = new Dictionary <Type, Action <object> > { { typeof(SubClass1), o => ((SubClass1)o).SomeMethod1() }, { typeof(SubClass2), o => ((SubClass2)o).SomeMethod2() } }; //probably best to check the type exists in the dictionary first, //maybe wrap up the execution into a class of it's own so it's abstracted away lookup[test.GetType()](test); }
public virtual T caseSubClass1(SubClass1 theEObject) { return(default(T)); }
public void Visit(SubClass1 item) => _parent.AddToDict(item, _value);
void AddToDict(SubClass1 item, int val) { subClass1Dict[item] = val; }
public bool Equals(SubClass1 other) => RecordTypeIgnoreBase <SubClass1> .EqualityTyped(this, other);
public int CompareTo(SubClass1 other) => RecordTypeIgnoreBase <SubClass1> .Compare(this, other);