public void PrimaryKeyExpression_2() { var record = new DoubleKey { StudentKey = 1, AdmissionNum = "123" }; var exp = EntityFrameworkHelper.PrimaryKeyExpression <DoubleKey>(); Assert.IsTrue(exp(record, new object[] { 1, "123" })); Assert.IsFalse(exp(record, new object[] { 2, string.Empty })); }
public void PrimaryKeyExpression_1() { var record = new SingleKey { StudentKey = 1 }; var exp = EntityFrameworkHelper.PrimaryKeyExpression <SingleKey>(); Assert.IsTrue(exp(record, new object[] { 1 })); Assert.IsFalse(exp(record, new object[] { 2 })); }
public void PrimaryKeyExpression_3() { var g = Guid.NewGuid(); var record = new TripleKey { StudentKey = 33, AdmissionNum = "1123223", Guid = g }; var exp = EntityFrameworkHelper.PrimaryKeyExpression <TripleKey>(); Assert.IsTrue(exp(record, new object[] { 33, "1123223", g })); Assert.IsFalse(exp(record, new object[] { 33, "1123223", Guid.NewGuid() })); }
public void PrimaryKeyExpression_2_ViaContext() { using IWindsorContainer c = new WindsorContainer(); c.AddDbContext <SampleContext>() .UseInMemory(); var ctx = c.Resolve <SampleContext>(); var record = new CompositeStringKey { Id = "1", Name = "123" }; var exp = EntityFrameworkHelper.PrimaryKeyExpression <CompositeStringKey>(ctx); Assert.IsTrue(exp(record, new object[] { "1", "123" })); Assert.IsFalse(exp(record, new object[] { "2", string.Empty })); }