private static Type GetDeclaringType(RelatedEnd relatedEnd)
 {
     if (relatedEnd.NavigationProperty != null)
     {
         var declaringEntityType = (EntityType)relatedEnd.NavigationProperty.DeclaringType;
         var mapping             = Util.GetObjectMapping(declaringEntityType, relatedEnd.WrappedOwner.Context.MetadataWorkspace);
         return(mapping.ClrType.ClrType);
     }
     else
     {
         return(relatedEnd.WrappedOwner.IdentityType);
     }
 }
Example #2
0
        private Plan GetPlan(DataRecordInfo recordInfo)
        {
            DebugCheck.NotNull(recordInfo);
            DebugCheck.NotNull(recordInfo.RecordType);

            var plans = _lastPlans ?? (_lastPlans = new Plan[MaxPlanCount]);

            // find an existing plan in circular buffer
            var index = _lastPlanIndex - 1;

            for (var i = 0; i < MaxPlanCount; ++i)
            {
                index = (index + 1) % MaxPlanCount;
                if (null == plans[index])
                {
                    break;
                }
                if (plans[index].Key
                    == recordInfo.RecordType)
                {
                    _lastPlanIndex = index;
                    return(plans[index]);
                }
            }
            Debug.Assert(0 <= index, "negative index");
            Debug.Assert(index != _lastPlanIndex || (null == plans[index]), "index wrapped around");

            // create a new plan
            var mapping = Util.GetObjectMapping(recordInfo.RecordType.EdmType, _workspace);

            Debug.Assert(null != mapping, "null ObjectTypeMapping");

            Debug.Assert(
                Helper.IsComplexType(recordInfo.RecordType.EdmType),
                "IExtendedDataRecord is not ComplexType");

            _lastPlanIndex = index;
            plans[index]   = new Plan(recordInfo.RecordType, mapping, recordInfo.FieldMetadata);
            return(plans[index]);
        }