Ejemplo n.º 1
0
        public void InequalityTest()
        {
            var builder = new MetadataModelBuilder();

            builder.Entity <Invoice>().Property(p => p.ReceiptType);
            builder.Entity <Invoice>().Property(p => p.ReceiptNumber);
            builder.Entity <Invoice>().Property(p => p.Id);
            builder.Entity <Invoice>().Property(p => p.ReceiptDate);
            builder.Entity <Invoice>().PrimaryKey.Add("ReceiptNumber");
            builder.Entity <Invoice>().PrimaryKey.Add("ReceiptType");
            var model = builder.ToModel();

            var entity  = model.GetEntityMetadata <Invoice>();
            var invoice = new Invoice {
                ReceiptNumber = "TestNumber", ReceiptType = ReceiptType.Invoice
            };

            var key   = entity.GetPrimaryKeyObject(invoice);
            var typed = key as EntityKey <string, ReceiptType>;

            var keycompare = new EntityKey <string, ReceiptType>(entity)
            {
                Value0 = "Bla",
                Value1 = ReceiptType.Invoice
            };

            Assert.NotEqual(key.GetHashCode(), keycompare.GetHashCode());
            Assert.NotEqual(key, keycompare);
        }
                internal DirectionalRelationship(EntityKey toEntityKey, AssociationEndMember fromEnd, AssociationEndMember toEnd, AssociationSet associationSet, IEntityStateEntry stateEntry)
                {
                    ToEntityKey    = EntityUtil.CheckArgumentNull(toEntityKey, "toEntityKey");
                    FromEnd        = EntityUtil.CheckArgumentNull(fromEnd, "fromEnd");
                    ToEnd          = EntityUtil.CheckArgumentNull(toEnd, "toEnd");
                    AssociationSet = EntityUtil.CheckArgumentNull(associationSet, "associationSet");
                    StateEntry     = EntityUtil.CheckArgumentNull(stateEntry, "stateEntry");
                    _equivalenceSetLinkedListNext = this;

                    _hashCode = toEntityKey.GetHashCode() ^
                                fromEnd.GetHashCode() ^
                                toEnd.GetHashCode() ^
                                associationSet.GetHashCode();
                }
 public override int GetHashCode()
 {
     return(AssociationSet.Name.GetHashCode() ^ (Key0.GetHashCode() + Key1.GetHashCode()));
 }
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     return(EntityKey.GetHashCode());
 }