/// <summary>
        /// Flattens a SetOpVar (used in SetOps). Simply produces a list of 
        /// properties corresponding to each desired property
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        private VarInfo FlattenSetOpVar(SetOpVar v)
        {
            if (TypeUtils.IsCollectionType(v.Type))
            {
                md.TypeUsage newType = GetNewType(v.Type);
                Var newVar = m_command.CreateSetOpVar(newType);
                return m_varInfoMap.CreateCollectionVarInfo(v, newVar);
            }
            else if (md.TypeSemantics.IsEnumerationType(v.Type) || md.TypeSemantics.IsStrongSpatialType(v.Type))
            {
                md.TypeUsage newType = GetNewType(v.Type);
                Var newVar = m_command.CreateSetOpVar(newType);
                return m_varInfoMap.CreatePrimitiveTypeVarInfo(v, newVar);
            }

            // Get the "new" type for the Var
            TypeInfo typeInfo = m_typeInfo.GetTypeInfo(v.Type);
            // Get a list of properties that we think are necessary 
            PropertyRefList desiredProperties = m_varPropertyMap[v];
            List<Var> newVars = new List<Var>();
            List<md.EdmProperty> newProps = new List<md.EdmProperty>();
            bool hasNullSentinelVar = false;
            foreach (PropertyRef p in typeInfo.PropertyRefList)
            {
                if (!desiredProperties.Contains(p))
                {
                    continue;
                }
                md.EdmProperty newProperty = typeInfo.GetNewProperty(p);
                newProps.Add(newProperty);
                SetOpVar newVar = m_command.CreateSetOpVar(md.Helper.GetModelTypeUsage(newProperty));
                newVars.Add(newVar);
             
                // Check if it is a null sentinel var
                if (!hasNullSentinelVar && IsNullSentinelPropertyRef(p))
                {
                    hasNullSentinelVar = true;
                }
            }
            VarInfo varInfo = m_varInfoMap.CreateStructuredVarInfo(v, typeInfo.FlattenedType, newVars, newProps, hasNullSentinelVar);
            return varInfo;
        }
Beispiel #2
0
 /// <summary>
 /// Creates a SetOp Var of
 /// </summary>
 /// <param name="type">Datatype of the Var</param>
 /// <returns>A new SetOp Var with the specified result type</returns>
 internal SetOpVar CreateSetOpVar(TypeUsage type)
 {
     SetOpVar v = new SetOpVar(NewVarId(), type);
     m_vars.Add(v);
     return v;
 }