Gccg 1.1.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Gccg --version 1.1.1
NuGet\Install-Package Gccg -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Gccg" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Gccg --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Gccg, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Gccg as a Cake Addin #addin nuget:?package=Gccg&version=1.1.1 // Install Gccg as a Cake Tool #tool nuget:?package=Gccg&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
usage
using DbContext (only for Entity Framework)
Gccg.Core.Generator.Generate({DbContext object}); ex) Gccg.Core.Generator.Generate(new ChinookContext());
using schema file
Gccg.Core.Generator.Generate({schema file path}); ex) Gccg.Core.Generator.Generate(@"C:\git\Gccg\Examples\Chinook\Chinnok.Gccg\Chinook.json");
Check out README.md in GitHub repository for basic usage and examples. https://github.com/cplkimth/Gccg
internal static class Program
{
private const int Sleep = 1500;
private static readonly DbContext _dbContext = new ChinookContext();
private const string SolutionName = "Chinook";
private const string Root = @$"D:\git\Gccg\Examples\{SolutionName}";
private const string DataEF = $@"{Root}\{SolutionName}.Data\EF";
private const string GccgEF = $@"{Root}\{SolutionName}.Gccg\EF";
private const string ContextPostfix = $@"*Context.cs";
private static void Main(string[] args)
{
Console.WriteLine($"[{DataEF}] 프로젝트에서 EF Core Power Tools를 실행하였습니까?");
var commands = (Command[])Enum.GetValues(typeof(Command));
foreach (var command in commands)
Console.WriteLine($"{(int)command} : {command}");
var commandInput = (Command)int.Parse(Console.ReadLine()!);
switch (commandInput)
{
case Command.Preparation:
Prepare();
break;
case Command.Generatation:
Generate();
break;
}
Console.WriteLine("done!");
}
private static void Prepare()
{
Console.WriteLine($"deleting [{GccgEF}]");
Directory.Delete(GccgEF, true);
Thread.Sleep(Sleep);
Console.WriteLine($"copying [{DataEF}] to [{GccgEF}]");
CopyDirectory(DataEF, GccgEF, true);
Thread.Sleep(Sleep);
var contextFile = Directory.GetFiles(DataEF, ContextPostfix).FirstOrDefault();
Console.WriteLine($"removing OnConfiguring in [{contextFile}]");
var lines = File.ReadAllLines(contextFile);
var indexToMove = FindIndexToDelete(lines, "protected override void OnConfiguring");
if (indexToMove != -1)
{
var result = new List<string>();
result.AddRange(lines.Take(indexToMove));
result.AddRange(lines.Skip(indexToMove + 3));
File.WriteAllLines(contextFile, result);
Thread.Sleep(Sleep);
}
Thread.Sleep(Sleep);
}
private static void Generate()
{
var json = Generator.Generate(_dbContext);
File.WriteAllText($"{SolutionName}.json", json);
}
private static int FindIndexToDelete(string[] lines, string text)
{
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].Contains(text))
return i;
}
return -1;
}
static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)
{
// Get information about the source directory
var dir = new DirectoryInfo(sourceDir);
// Check if the source directory exists
if (!dir.Exists)
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
// Cache directories before we start copying
DirectoryInfo[] dirs = dir.GetDirectories();
// Create the destination directory
if (Directory.Exists(destinationDir) == false)
Directory.CreateDirectory(destinationDir);
// Get the files in the source directory and copy to the destination directory
foreach (FileInfo file in dir.GetFiles())
{
string targetFilePath = Path.Combine(destinationDir, file.Name);
file.CopyTo(targetFilePath, true);
}
// If recursive and copying subdirectories, recursively call this method
if (recursive)
{
foreach (DirectoryInfo subDir in dirs)
{
string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
CopyDirectory(subDir.FullName, newDestinationDir, true);
}
}
}
}
public enum Command
{
Preparation = 1,
Generatation
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.1)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.1)
- Microsoft.EntityFrameworkCore.SqlServer.HierarchyId (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.