I want this to be as simple as possible to use successfully. A developer should only need to to complete the following steps to use the eventual NuGet package:
- Add a reference to the NuGet package from the project where they want to include and use the
.sqlfiles. - Add the following section to their .csproj file:
<ItemGroup> <AdditionalFiles Include="**\*.sql" /> </ItemGroup> - Add a file to their project ending in
.sql. - Use the static class
SqlFilesto access the contents of their.sqlfiles as strings in their code:var sqlString = SqlFiles.SomeQuery;
To avoid burdening users with further requirements than those listed in the Usage section, the following conventions are used.
To avoid restricting users' options for organizing their SQL files, both the file path and name are used to determine the const string location within SqlFiles.
Static inner classes are generated for each subdirectory in the file path, thereby providing a navigation chain reflecting the file system organization.
For example:
- Given a SQL file at: /Repositories/Widgets/Queries/GetWidgets.sql
- Access const string: SqlFiles.Repositories.Widgets.Queries.GetWidgets