/// <summary> /// Creates a Custom Model assembly with given name and extended type definitions and saves it to assemblyName.dll /// </summary> /// <param name="assemblyName">The name of the assembly (will be saved as assemblyName.dll)</param> /// <param name="extendedTables">The enumeration of extended tables to be implemented</param> public static void CreateCustomModelAssembly(string assemblyName, IEnumerable <ExtendedTable> extendedTables) { string assemblyFileName = assemblyName + ".dll"; var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(assemblyName), AssemblyBuilderAccess.RunAndSave); var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyFileName, assemblyFileName); var derivedTypes = new List <Type>(); var tableMappings = new TableMappings(); foreach (var extendedTable in extendedTables) { var tableMapping = new TableMapping(extendedTable.TableName); foreach (var extendedType in extendedTable.Types) { var derivedType = CreateDerivedType(moduleBuilder, extendedTable, extendedType); derivedTypes.Add(derivedType); tableMapping.Add(new TypeMapping(extendedType.BaseType, derivedType)); } tableMappings.Add(tableMapping); } SerializeMappings(assemblyName, tableMappings); assemblyBuilder.Save(assemblyFileName); }
protected DataAdapter(DataAdapter from) { AcceptChangesDuringFill = from.AcceptChangesDuringFill; ContinueUpdateOnError = from.ContinueUpdateOnError; MissingMappingAction = from.MissingMappingAction; MissingSchemaAction = from.MissingSchemaAction; if (from.tableMappings != null) { foreach (ICloneable cloneable in from.TableMappings) { TableMappings.Add(cloneable.Clone()); } } acceptChangesDuringUpdate = from.AcceptChangesDuringUpdate; fillLoadOption = from.FillLoadOption; returnProviderSpecificTypes = from.ReturnProviderSpecificTypes; }
protected DataAdapter(DataAdapter adapter) { AcceptChangesDuringFill = adapter.AcceptChangesDuringFill; ContinueUpdateOnError = adapter.ContinueUpdateOnError; MissingMappingAction = adapter.MissingMappingAction; MissingSchemaAction = adapter.MissingSchemaAction; if (adapter.tableMappings != null) { foreach (ICloneable cloneable in adapter.TableMappings) { TableMappings.Add(cloneable.Clone()); } } #if NET_2_0 acceptChangesDuringUpdate = adapter.AcceptChangesDuringUpdate; fillLoadOption = adapter.FillLoadOption; returnProviderSpecificTypes = adapter.ReturnProviderSpecificTypes; #endif }