コード例 #1
0
        private IEnumerable <EfColumnInfo> DecodeComplexTypes(ComplexPropertyMapping complexMapping, Type parentClass)
        {
            //throw new NotImplementedException("We do not currently handle complex properties");
            var complexCols = new List <EfColumnInfo>();

            foreach (var property in complexMapping.TypeMappings.SelectMany(x => x.PropertyMappings))
            {
                var complexClrType =
                    Ef6MetadataDecoder.GetPublicAndPrivatePropertyByName(parentClass, complexMapping.Property.Name)
                    .PropertyType;
                if (property.Property.IsComplexType)
                {
                    complexCols.AddRange(DecodeComplexTypes((ComplexPropertyMapping)property, complexClrType));
                }
                else
                {
                    var columnName  = ((ScalarPropertyMapping)property).Column.Name;
                    var sqlTypeName = _tableEntitySet.ElementType.DeclaredMembers
                                      .Single(x => x.Name == columnName).TypeUsage.EdmType.Name;
                    var clrProperty = Ef6MetadataDecoder.GetPublicAndPrivatePropertyByName(complexClrType, property.Property.Name);
                    complexCols.Add(new EfColumnInfo(columnName, sqlTypeName, property.Property.Nullable,
                                                     property.Property.MaxLength, property.Property.Precision, null, clrProperty));
                }
            }
            return(complexCols);
        }
コード例 #2
0
        public List <EfColumnInfo> DecodeTableProperties(EntitySet entitySet, Type clrClassType, List <EfKeyOrder> primaryKeys)
        {
            var columnInfos = new List <EfColumnInfo>();

            foreach (var edmProperty in entitySet.ElementType.DeclaredProperties)
            {
                if (edmProperty.IsComplexType)
                {
                    var complexColumn = _mapping.EntityTypeMappings.Single()
                                        .Fragments.Single()
                                        .PropertyMappings.OfType <ComplexPropertyMapping>().Single(m => m.Property == edmProperty);
                    columnInfos.AddRange(DecodeComplexTypes(complexColumn, clrClassType));
                }
                else
                {
                    //normal column
                    var columnName = _mapping.EntityTypeMappings.Single()
                                     .Fragments.Single()
                                     .PropertyMappings.OfType <ScalarPropertyMapping>()
                                     .Single(m => m.Property == edmProperty)
                                     .Column.Name;
                    var sqlTypeName = _tableEntitySet.ElementType.DeclaredMembers
                                      .Single(x => x.Name == columnName).TypeUsage.EdmType.Name;
                    var clrProperty = Ef6MetadataDecoder.GetPublicAndPrivatePropertyByName(clrClassType, edmProperty.Name);
                    var primaryKey  = primaryKeys.SingleOrDefault(x => x.Name == edmProperty.Name);
                    columnInfos.Add(new EfColumnInfo(columnName, sqlTypeName, edmProperty.Nullable,
                                                     edmProperty.MaxLength, edmProperty.Precision, primaryKey, clrProperty));
                }
            }

            return(columnInfos);
        }
コード例 #3
0
        /// <summary>
        /// This compares the dbContext against the given sql database
        /// </summary>
        /// <param name="db"></param>
        /// <param name="classesAssembly"></param>
        /// <returns></returns>
        public ISuccessOrErrors CompareEfPart(DbContext db, Assembly classesAssembly)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            var decoder = new Ef6MetadataDecoder(classesAssembly);
            var efInfos = decoder.GetAllEfTablesWithColInfo(db);

            return(_comparer.CompareEfWithSql(efInfos, _allSqlInfo));
        }