Coder Social home page Coder Social logo

score-service's Introduction

A score-keeping service for games written as an ASP.NET Core Web API, with endpoints for adding, retrieving, and deleting scores.

This project uses a custom abstraction mechanism to simplify access to a MySQL database. To access a database, an interface can be created, and the methods can be annotated with the SqlQuery or SqlUpdate attributes to specify the SQL commands they should execute. The method parameters are automatically mapped to query parameters, and query results are automatically mapped to return values.

Example:

public class HighScore
{
    public string name;
    public int score;
}

public interface HighScoreService
{
    [SqlQuery("select `name`, `score` from `scores` where `game`=@game order by `score` desc limit @max")]
    List<HighScore> GetScores(string game, int max);
}

// `ProxyFactory` generates an implementation of `HighScoreService` at runtime
// which forwards all method calls to `SqlProxyTarget`, which executes the
// appropriate SQL commands based on the `SqlQuery` or `SqlUpdate` attributes
// attached to each interface method.

var proxyTarget = new SqlProxyTarget("MySQL connection string");
var highScoreService = ProxyFactory.Create<HighScoreService>(proxyTarget);
List<HighScore> scores = highScoreService.GetScores("my game", 100);
PrintAllScores(scores);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.