// Setting Columns : display name, allow null private bool?ShowColumnSetting() { var modelType = _codeGeneratorViewModel.ModelType.CodeType; string savefolderPath = Path.Combine(Context.ActiveProject.GetFullPath(), "CodeGen"); StorageMan <MetaTableInfo> sm = new StorageMan <MetaTableInfo>(modelType.Name, savefolderPath); MetaTableInfo data = sm.Read(); if (data.Columns.Any()) { _ModelMetadataVM = new ModelMetadataViewModel(data); } else { string dbContextTypeName = _codeGeneratorViewModel.DbContextModelType.TypeName; ICodeTypeService codeTypeService = GetService <ICodeTypeService>(); CodeType dbContext = codeTypeService.GetCodeType(Context.ActiveProject, dbContextTypeName); IEntityFrameworkService efService = Context.ServiceProvider.GetService <IEntityFrameworkService>(); ModelMetadata efMetadata = efService.AddRequiredEntity(Context, dbContextTypeName, modelType.FullName); _ModelMetadataVM = new ModelMetadataViewModel(efMetadata); } ModelMetadataDialog dialog = new ModelMetadataDialog(_ModelMetadataVM); bool?isOk = dialog.ShowModal(); if (isOk == true) { sm.Save(_ModelMetadataVM.DataModel); } return(isOk); }
// Setting Columns : display name, allow null private bool?ShowColumnSetting() { var modelType = _codeGeneratorViewModel.ModelType.CodeType; string savefolderPath = Path.Combine(path1: Context.ActiveProject.GetFullPath(), path2: "CodeGen"); StorageMan <MetaTableInfo> sm = new StorageMan <MetaTableInfo>(modelTypeName: modelType.Name, savefolderPath: savefolderPath); MetaTableInfo data = sm.Read(); if (data.Columns.Any()) { _ModelMetadataVM = new ModelMetadataViewModel(dataModel: data); } else { //string dbContextTypeName = _codeGeneratorViewModel.DbContextModelType.TypeName; //ICodeTypeService codeTypeService = GetService<ICodeTypeService>(); //CodeType dbContext = codeTypeService.GetCodeType(project: Context.ActiveProject, fullName: dbContextTypeName); //IEntityFrameworkService efService = Context.ServiceProvider.GetService<IEntityFrameworkService>(); //ModelMetadata efMetadata = efService.AddRequiredEntity(context: Context, contextTypeFullName: dbContextTypeName, entityTypeFullName: modelType.FullName); var fullName = modelType.FullName; var efMetadata = GetEfMetadata(fullName); _ModelMetadataVM = new ModelMetadataViewModel(efMetadata: efMetadata); } ModelMetadataDialog dialog = new ModelMetadataDialog(viewModel: _ModelMetadataVM); bool?isOk = dialog.ShowModal(); if (isOk == true) { sm.Save(data: _ModelMetadataVM.DataModel); } return(isOk); }