KullGames_ServerLists_DataAccess 1.0.20241028.964

dotnet add package KullGames_ServerLists_DataAccess --version 1.0.20241028.964                
NuGet\Install-Package KullGames_ServerLists_DataAccess -Version 1.0.20241028.964                
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="KullGames_ServerLists_DataAccess" Version="1.0.20241028.964" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KullGames_ServerLists_DataAccess --version 1.0.20241028.964                
#r "nuget: KullGames_ServerLists_DataAccess, 1.0.20241028.964"                
#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 KullGames_ServerLists_DataAccess as a Cake Addin
#addin nuget:?package=KullGames_ServerLists_DataAccess&version=1.0.20241028.964

// Install KullGames_ServerLists_DataAccess as a Cake Tool
#tool nuget:?package=KullGames_ServerLists_DataAccess&version=1.0.20241028.964                

KullGames_ServerLists_DataAccess Library

Overview

The KullGames_ServerLists_DataAccess library is a .NET 8.0 data access layer designed for interacting with Minecraft server listings. It utilizes Entity Framework Core and supports multiple database providers such as MySQL, PostgreSQL, SQLite, SQL Server, Firebird, In-Memory, and Cosmos DB. The library provides an interface IDataAccess for performing CRUD operations on Users, Servers, and ServerTags.

Features

  • Multi-Database Support: Easily switch between different database providers.
  • Entity Framework Core: Leverages EF Core for ORM capabilities.
  • Asynchronous Operations: Fully asynchronous methods for non-blocking operations.
  • Extensible: Designed to be extended or modified for additional functionalities.
  • Modular Design: Separates EF models into the KullGames_ServerLists_EfModels project for better modularity.

Requirements

  • .NET 8.0 SDK
  • Visual Studio 2022 or higher (optional for development)
  • Database Provider (MySQL, PostgreSQL, SQLite, etc.)

Installation

Add the library to your project by referencing it in your .csproj file:

<ProjectReference Include="..\KullGames_ServerLists_DataAccess\KullGames_ServerLists_DataAccess.csproj" />

Ensure that you also include the KullGames_ServerLists_EfModels project:

<ProjectReference Include="..\KullGames_ServerLists_EfModels\KullGames_ServerLists_EfModels.csproj" />

Usage

Setting up DataAccess

Create an instance of DataAccess by providing DataAccessOptions:

using KullGames_ServerLists_DataAccess;
using KullGames_ServerLists_EfModels;

var options = new DataAccessOptions
{
    DatabaseType = DatabaseType.MySQL,
    ConnectionString = "your-connection-string",
    MySqlServerVersion = new MySqlServerVersion(new Version(8, 0, 21)),
    ReuseContext = true
};

IDataAccess dataAccess = new DataAccess(options);

Performing CRUD Operations

Users
// Create a new user
var user = new User
{
    Id = Guid.NewGuid(),
    Username = "PlayerOne",
    Email = "playerone@example.com"
};

await dataAccess.SaveUserAsync(user);

// Fetch a user
var fetchedUser = await dataAccess.GetUserAsync(user.Id);

// Delete a user
await dataAccess.DeleteUserAsync(user.Id);
Servers
// Create a new server
var server = new Server
{
    Id = Guid.NewGuid(),
    Name = "Awesome Minecraft Server",
    OwnerId = user.Id,
    IPAddress = "192.168.1.100",
    Port = 25565
};

await dataAccess.SaveServerAsync(server);

// Fetch servers
var servers = await dataAccess.GetServersAsync(new[] { server.Id });

// Delete a server
await dataAccess.DeleteServerAsync(server.Id);
ServerTags
// Create a new server tag
var tag = new ServerTag
{
    Id = Guid.NewGuid(),
    TagName = "Survival"
};

await dataAccess.SaveServerTagAsync(tag);

// Fetch server tags
var tags = await dataAccess.GetServerTagsAsync(new[] { tag.Id });

// Delete a server tag
await dataAccess.DeleteServerTagAsync(tag.Id);

Supported Databases

  • MySQL/MariaDB
  • PostgreSQL
  • SQLite
  • SQL Server
  • Firebird
  • In-Memory Database (For testing)
  • Cosmos DB

Configuration Options

DataAccessOptions allows you to configure the data access layer:

  • DatabaseType: Specifies the type of database to use.
  • ConnectionString: The connection string for your database.
  • MySqlServerVersion: Required for MySQL/MariaDB.
  • SqliteFilePath: File path for SQLite database.
  • ReuseContext: Whether to reuse the same DbContext instance.
  • Additional properties for specific databases like Cosmos DB.

Project Structure

  • KullGames_ServerLists_DataAccess: Contains the data access layer implementation.
  • KullGames_ServerLists_EfModels: Contains the Entity Framework models and ServerListDbContext.

Building the Project

To build the project locally:

  1. Clone the repository:

    git clone https://dev.azure.com/KullGamesRepo/KullGames/_git/KullGames_ServerLists
    
  2. Navigate to the project directory:

    cd KullGames_ServerLists
    
  3. Restore dependencies and build:

    dotnet restore
    dotnet build
    

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Create a pull request.

License

This project is licensed under the CC BY-NC 4.0 License - see the LICENSE file for full details.

You are free to:

- **Share**: Copy and redistribute the material in any medium or format.
- **Adapt**: Remix, transform, and build upon the material.

Under the following terms:

- **Attribution**: You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- **NonCommercial**: You may not use the material for commercial purposes.

Contact

For questions or support, please visit KullGames or open an issue in the repository.

Product 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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on KullGames_ServerLists_DataAccess:

Package Downloads
KullGames_ServerLists_DataAccessClient

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.20241028.964 75 10/28/2024
1.0.20241025.953 81 10/25/2024

Initial release.