# Monolith Utils Setup
Our tool is 100% command line, and VERY powerful!
Before continuing, it's best to have a command-line accessible text editor. If you don't already have one, consider using Visual Studio Code
Open up a linux-based command line tool (Github has one or you can use WSL).
touch ~/.bashrc && code ~/.bashrc
In your .bashrc
file, add the following lines to the bottom of your file:
/mnt
before all file paths.alias deref="/c/…/Monolith-Utils/Deref/bin/debug/net8.0/deref.exe"
Save and close.
Back at your command line, type the following:
source ~/.bashrc
deref --help
Should see output.
There are 2 main libraries that are versioned in this repository:
delinq
- Used to convert LINQ queries to Repository pattern.deref
- Used to understand all solutions and projects in a monolith directory structure.This app will parse a LINQ designer file and extract the necessary data that it needs to recreate the queries to a backing "Repository" approach. This will allow the queries to be run against a database without the need for the LINQ designer file.
This is a command line tool that is intended to generate properly formatted C# code for any Repository with valid unit tests which ensure the methods are protected from future changes.
Before we can generate code, we must first define what methods and parameters are used in the existing implementation.
$> delinq init "c:\temp\SomeDataContext.dbml"
This will create a SomeData.metadata.settings
file which contains all the information needed to generate repository methods and unit tests.
We defined a standard approach for calling the database.
DataModels.cs
- Contains all of the DTO
objects in one code file.DataContext.cs
- A new (very light-weight) implementation of the original DataContext.IRepository.cs
- An interface of all required methods that match the original DataContext methods.Repository.cs
- The customized implementation of all stored procedure calls.IRepositorySettings.cs
- The interface that is given to the repository for configurations needed to connect to the database.RepositorySettings.cs
- The implementation of reading the connection settings from a config file.Here is the line of code that will generate all of the above files:
$> delinq repo "c:\temp\SomeData.metadata.settings" -o "c:\temp\SomeData\RepoFiles"
If you only need to generate code for a specific method, you can define it using a flag:
$> delinq repo "c:\temp\SomeData.metadata.settings" -o "c:\temp\SomeData\RepoFiles" -m SomeSpecificMethodName
This is useful if you only have to generate code for a specific database call.
We defined a standard approach for testing our repository methods.
var
, etc...)NonQuery
, QueryMany
and QuerySingle
database calls.Here is the line of code that will generate all of the above files:
$> delinq tests "c:\temp\SomeData.metadata.settings" -o "c:\temp\SomeData\TestFiles"
If you only need to generate test code for a specific repository method, you can define it using a flag:
$> delinq tests "c:\temp\SomeData.metadata.settings" -o "c:\temp\SomeData\TestFiles" -m SomeSpecificMethodName
This is useful if you only have to generate code for a specific database call.
This is used to ensure that we have accounted for proper implementations of the repository methods.
$> delinq verify "c:\temp\SomeRepository.cs" SECRET:ConnectionStrings.InCode -o "c:\temp\Verification.json"
Note: This requires user secrets to be set up for the connection string.
dotnet user-secrets init
dotnet user-secrets set "ConnectionStrings:InCode" "YourConnectionString"
Reads the json file generated from the verify
results and generates a report of the findings.
NOTE: The results are output to "csv" format, but can be opened in Excel to filter and sort results easily.
$> delinq report "c:\temp\Verification.json"
For now, we don't have a lot of information, as it's evolving very fast.
For now, simply use the following:
deref --help
deref branch --help
deref init --help
deref project --help
deref solution --help
deref wix --help
Feel free to use the custom calls defined in the Delinq/Properties/launchSettings.json
file to get started.