Beispiel #1
0
        private CompositeKey BuildAggregateKey(Object theObject, Boolean useSource)
        {
            //not a great implementation...we will start with this though
            if (theObject == null)
                throw new DataMapperException("unable to build aggregatekey for object");

            CompositeKey key = new CompositeKey();

            //the order matters but it should be preserved, right?
            foreach (var item in this.PropertyMapList.Where(a => a.IsKey))
            {
                var propertyInfoToUse = useSource ? item.SourcePropertyInfo : item.TargetPropertyInfo;

                var value = propertyInfoToUse.GetValue(theObject, null);

                key.AddKey(propertyInfoToUse.PropertyType, value);
            }

            return key;
        }