public static DataSet CreateDataSetForConfig(IDataTableConfig config) { var dataset = new DataSet(); foreach (var record in config.Records) { CreateTableforRecord(dataset, record); } return(dataset); }
/// <summary> /// 创建关系映射图 /// </summary> /// <param name="type">映射类型</param> /// <returns>关系映射图</returns> private static DataMapping CreateMapping(Type type) { string tableName = null; string extentParam = null; bool isEntityTable = true; DataMapping dataMapping = null; IDataTableConfig config = ConfigManager.LoadDataTableConfig(type); if (config != null) { tableName = config.TableName; extentParam = config.ExtendParams; isEntityTable = config.IsEntityTable; } if (string.IsNullOrEmpty(tableName)) { tableName = type.Name; } if (type.IsSubclassOf(typeof(DataTableEntity))) { dataMapping = new DataTableEntityMapping(type, tableName, true); } else if (type.IsSubclassOf(typeof(DataEntity))) { dataMapping = new DataEntityMapping(type, tableName, true); } else { if (!isEntityTable) { dataMapping = new DataEntityMapping(type, tableName, false); } else { dataMapping = new DataTableEntityMapping(type, tableName, false); } } dataMapping.ExtentParams = new ExtendParamsCollection(extentParam); return(dataMapping); }
internal static IDataTableConfig LoadDataTableConfig(Type type) { IDataTableConfig config = null; if (config == null) { LightDataConfig lightDataConfig = GetConfig(); if (lightDataConfig != null && lightDataConfig.ContainDataTableConfig(type)) { config = lightDataConfig.GetDataTableConfig(type); } } if (config == null) { DataTableAttribute[] attributes = AttributeCore.GetTypeAttributes <DataTableAttribute>(type, true); if (attributes.Length > 0) { config = attributes[0]; } } return(config); }