示例#1
0
        private void ValidateTableMapping(StormTableMappedAttribute mapping)
        {
            DataTable schema = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, mapping.TableName, null });
            if (schema.Rows.Count == 0)
                throw new StormConfigurationException("The table named [" + mapping.TableName + "] does not exist.");

            object tableCatalog = schema.Rows[0]["TABLE_CATALOG"];
            object tableSchema = schema.Rows[0]["TABLE_SCHEMA"];
            object tableName = schema.Rows[0]["TABLE_NAME"];

            foreach (PropertyLevelMappedAttribute propMapping in mapping.PropertyAttributes)
            {
                if (propMapping is StormColumnMappedAttribute)
                    ValidateColumnMapping(tableCatalog, tableSchema, tableName, (StormColumnMappedAttribute)propMapping);
                else if (!(propMapping is StormRelationMappedAttribute))
                    throw new StormConfigurationException("Unhandled mapping type. Data Binder does not know how to handle the mapping [" + propMapping.GetType().FullName + "].");
            }
        }
示例#2
0
        private void ValidateTableMapping(StormTableMappedAttribute mapping)
        {
            string tableName = null, owner = null;
            string[] parts = mapping.TableName.ToUpper().Split('.');
            if (parts.Length == 2)
            {
                owner = parts[0];
                tableName = parts[1];
            }
            else
                tableName = parts[0];

            DataTable schema = connection.GetSchema("Tables", new string[] { owner, tableName });
            if (schema.Rows.Count == 0)
                throw new StormConfigurationException("The table named [" + mapping.TableName + "] does not exist.");

            tableName = schema.Rows[0]["TABLE_NAME"].ToString();

            foreach (PropertyLevelMappedAttribute propMapping in mapping.PropertyAttributes)
            {
                if (propMapping is StormColumnMappedAttribute)
                    ValidateColumnMapping(tableName, (StormColumnMappedAttribute)propMapping);
                else if (!(propMapping is StormRelationMappedAttribute))
                    throw new StormConfigurationException("Unhandled mapping type. Data Binder does not know how to handle the mapping [" + propMapping.GetType().FullName + "].");
            }
        }