Scraps.Database 0.20.2

dotnet add package Scraps.Database --version 0.20.2
                    
NuGet\Install-Package Scraps.Database -Version 0.20.2
                    
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="Scraps.Database" Version="0.20.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Scraps.Database" Version="0.20.2" />
                    
Directory.Packages.props
<PackageReference Include="Scraps.Database" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Scraps.Database --version 0.20.2
                    
#r "nuget: Scraps.Database, 0.20.2"
                    
#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.
#:package Scraps.Database@0.20.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Scraps.Database&version=0.20.2
                    
Install as a Cake Addin
#tool nuget:?package=Scraps.Database&version=0.20.2
                    
Install as a Cake Tool

Scraps

Scraps - модульная .NET-библиотека для работы с данными: провайдеры БД (MSSQL и LocalFiles), роли/права, импорт/экспорт, локализация, утилиты DataTable и WinForms-хелперы.

Актуальная структура

Каждый модуль - отдельный пакет/проект:

Пакет Назначение
Scraps.Core конфигурация, локализация, DataTable-утилиты, модели безопасности (Scraps.Security)
Scraps.Database общие интерфейсы БД + фасад Scraps.Database.Current
Scraps.Database.MSSQL SQL Server провайдер + MSSQL-утилиты
Scraps.Database.LocalFiles локальный JSON/file-based провайдер
Scraps.Import импорт из Excel/CSV
Scraps.Export экспорт в Excel/PDF
Scraps.UI.WinForms расширения для DataGridView (net472)
Scraps мета-пакет, подтягивает все ключевые модули

Важно:

  • отдельного пакета Scraps.Security больше нет;
  • namespace Scraps.Security используется и доступен через Scraps.Core/Scraps.Database.

Быстрый старт (единый фасад Current)

using Scraps.Configs;
using Scraps.Database;

// 1) Выбор провайдера
ScrapsConfig.DatabaseProvider = DatabaseProvider.MSSQL;

// 2) Настройки подключения
ScrapsConfig.DatabaseName = "MyDb";
ScrapsConfig.ConnectionString = Current.ConnectionStringBuilder("MyDb");
// или вручную: "Server=.\\SQLEXPRESS;Database=MyDb;Trusted_Connection=True;"

// 3) Работа через единый фасад
bool ok = Current.TestConnection();
var tables = Current.GetTables();
var users = Current.GetTableData("Users");

DatabaseProviderFactory автоматически подхватывает нужный провайдер по ScrapsConfig.DatabaseProvider.

Примечание: в Current есть ConnectionStringBuilder(...).

  • для MSSQL параметр - имя БД или готовая connection string;
  • для LocalFiles параметр - путь к папке данных (или ScrapsConfig.LocalDataPath, если параметр не передан).

Основные API

Current (Scraps.Database)

  • Current.Connection, Current.Schema, Current.Data, Current.Users, Current.Roles, Current.RolePermissions
  • Current.GetTables(includeSystem: false)
  • Current.GetTableData(...), Current.GetTableDataExpanded(...)
  • Current.FindByColumn(table, column, value, SqlFilterOperator)
  • Current.ApplyTableChanges(...), Current.BulkInsert(...)
  • Current.AddRow(...), Current.UpdateRow(...)
  • Current.VirtualTables.*, Current.GetForeignKeys(...), Current.GetForeignKeyLookup(...)

Фильтрация (SqlFilterOperator)

Вместо exactMatch используется оператор:

using Scraps.Database;

var exact = Current.FindByColumn("Users", "Login", "admin", SqlFilterOperator.Eq);
var like = Current.FindByColumn("Users", "Login", "adm", SqlFilterOperator.Like);
var nulls = Current.FindByColumn("Users", "MiddleName", null, SqlFilterOperator.IsNull);

Роли и права

RoleManager удален. Используйте API провайдера:

using Scraps.Database;
using Scraps.Security;

bool canRead = Current.Roles.CheckAccess("Admin", "Users", PermissionFlags.Read);
var effective = Current.Roles.GetEffectivePermissions("Admin", "Users");

Сессия пользователя:

using Scraps.Security;

UserSession.Login("admin", "Password123!");

MSSQL-утилиты

Модуль Scraps.Database.MSSQL также содержит привычный статический API MSSQL (инициализация, генерация схемы, FK helpers, и т.д.) для сценариев, где нужен провайдер-специфичный функционал.

Import/Export

Import (Scraps.Import)

  • DataImportService.LoadExcelToDataTable(...)
  • DataImportService.LoadCsvToDataTable(...)
  • DataImportService.ValidateColumns/ValidateTypes/...
  • DataImportService.ImportToTable(...)

Export (Scraps.Export)

  • ReportExporter (Excel/PDF)
  • ReportDataBuilder

UI.WinForms (Scraps.UI.WinForms)

Модуль для net472:

  • расширения для выделения/фильтрации/поиска в DataGridView;
  • FK ComboBox-колонки и связанные хелперы.

Сборка, упаковка и публикация

Из корня репозитория:

./pack.sh
./publish-nuget.sh

Windows:

pack.bat
publish-nuget.bat

Что делает pack:

  • dotnet cleandotnet builddotnet pack
  • складывает .nupkg в папку NuGet/

publish-nuget:

  • публикует все пакеты из NuGet/ в NuGet.org;
  • использует --skip-duplicate и выводит счетчик успешных/неуспешных публикаций.

Тесты

dotnet test Scraps.Tests/Scraps.Tests.csproj

Замечания:

  • Scraps.Tests таргетит net472;
  • часть тестов зависит от Windows Forms и/или доступного SQL Server;
  • в Linux/CI без нужного окружения такие тесты могут быть недоступны.

Совместимость

  • Scraps.Core, Scraps.Database, Scraps.Database.LocalFiles: net45, net472, netstandard2.0
  • Scraps.Database.MSSQL: net451, net472, netstandard2.0
  • импорт/экспорт и мета-пакет (Import, Export, Scraps): net472, netstandard2.0
  • WinForms и тесты: net472

Примечание

Проект учебный. Перед production-использованием рекомендуется аудит безопасности, SQL-политик и архитектурных ограничений.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Scraps.Database:

Package Downloads
Scraps

Scraps — мета-пакет. Включает все модули: Core, Database.MSSQL, LocalFiles, Import, Export.

Scraps.Database.MSSQL

Scraps Database MSSQL — работа с Microsoft SQL Server.

Scraps.Import

Scraps Import — импорт данных из Excel и CSV.

Scraps.UI.WinForms

Scraps UI WinForms — хелперы для DataGridView и FK-редакторов.

Scraps.Database.LocalFiles

Scraps Database LocalFiles - local JSON/file-based database provider.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.20.2 582 4/25/2026