Ejemplo n.º 1
0
        private static SortedListAllowDupes <DatabaseColumn> GetMappedColumnsForConceptualProperty(ConceptualProperty property)
        {
            var columns = new SortedListAllowDupes <DatabaseColumn>(new DatabaseColumnComparer());

            if (property != null)
            {
                foreach (var sp in property.GetAntiDependenciesOfType <ScalarProperty>())
                {
                    // only want scalar props for a mapping fragment, not for an association set mapping
                    if (sp.Parent is MappingFragment)
                    {
                        if (sp.ColumnName.Target == null)
                        {
                            Debug.Fail("Null target for " + sp.ToPrettyString());
                        }
                        else
                        {
                            // in the situation where property is in multiple EntityTypeMappings (an inheritance
                            // hierarchy) there can be multiple ScalarProperty anti-dependencies of property
                            // (one for each EntityTypeMapping) all of which map to the same DatabaseColumn -
                            // in this case only insert the first of these
                            var dbCol = DatabaseColumn.CreateFromProperty(sp.ColumnName.Target);
                            if (!columns.Contains(dbCol))
                            {
                                columns.Add(dbCol);
                            }
                        }
                    }
                }
            }
            return(columns);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     returns list of StorageProperties mapped to a ConceptualProperty via an EntitySetMapping
 ///     or an EntityTypeMapping
 /// </summary>
 /// <param name="cProp"></param>
 /// <returns></returns>
 private static IEnumerable <StorageProperty> MappedStorageProperties(ConceptualProperty cProp)
 {
     Debug.Assert(null != cProp, "null ConceptualProperty");
     if (null != cProp)
     {
         // loop over ConceptualProperties mapped to this ConceptualProperty
         foreach (var sp in cProp.GetAntiDependenciesOfType <ScalarProperty>())
         {
             // only use ScalarProperty elements inside an EntitySetMapping or EntityTypeMapping
             // (MappingFragment is only used by those types of mappings)
             if (null != sp.GetParentOfType(typeof(MappingFragment)))
             {
                 var sProp = sp.ColumnName.Target as StorageProperty;
                 if (null != sProp)
                 {
                     yield return(sProp);
                 }
             }
         }
     }
 }