示例#1
0
 private void populateLists() {
     GeneratorOptions options = new GeneratorOptions() { SupportsReturnValue = schema.Platform == "SQLSERVER" };
     IDataAccessGenerator gen1 = new CSharpDataAccessGenerator(null, options);
     cmbGenerator.Items.Add(new DalGeneratorItem(gen1.GetName(), gen1));
     
     
     cmbTypeMap.Items.Add(new TypeMapItem("No Type Map", null));
     ResourceManager resMan = new ResourceManager();
     foreach (TypeMap tm in resMan.GetDataAccessTypeMaps())
     {
         TypeMapItem item = new TypeMapItem(tm.Name, tm);
         cmbTypeMap.Items.Add(item);
     }
     cmbTypeMap.Items.Add(new TypeMapItem("Custom", null));
 }
示例#2
0
        public override void Execute(IDictionary<string, object> scope)
        {
            try
            {
                this.Status = OperationStatus.RUNNING;
                SqlConnection conn = scope["CONNECTION"] as SqlConnection;
                Schema schema = scope["SCHEMA"] as Schema;
                DatabaseExplorer exp = new DatabaseExplorer(conn, new SQLServerDefaultConf());
               
                INamingAdapter adapter = null;
                if (useCSNaming)
                {
                    adapter = new CSNamingAdapter();
                }
                else
                {
                    adapter = new SameNamingAdapter();
                }

                GeneratorOptions options = new GeneratorOptions() { SupportsReturnValue = true, NamingAdapter = new CSNamingAdapter() };

                ResourceManager resMan = new ResourceManager();
                List<TypeMap> tts = resMan.GetDataAccessTypeMaps();
                TypeMap tm = resMan.GetDataAccessTypeMaps().Where<TypeMap>(t => t.Name == "SqlServer -> C# Standard Type Map").FirstOrDefault<TypeMap>();
                CSharpDataAccessGenerator gen = new CSharpDataAccessGenerator(tm, options);

                string entitiesCode = gen.GenerateEntities(schema);
                string entityFile = Path.Combine(dalLocation, "Entities.cs");
                saveToFile(entityFile, entitiesCode);

                string interfaceCode = gen.GenerateInterface(schema);
                string interfaceFile = Path.Combine(dalLocation, "IDataStore.cs");
                saveToFile(interfaceFile, interfaceCode);

                string storeCode = gen.GenerateClass(schema);
                string storeFile = Path.Combine(dalLocation, "DataStore.cs");
                saveToFile(storeFile, storeCode);
                this.Status = OperationStatus.COMPLETED;
                
            }
            catch (Exception ex)
            {
                this.Exception = ex;
                this.Status = OperationStatus.FAILED;
                throw ex;
            }
        }
 public CSharpDataAccessGenerator(TypeMap typeMap, GeneratorOptions options)
 {
     this.TypeMap = typeMap;
     this.Options = options;
 }