All Projects → khellang → EFCore.Sqlite.NodaTime

khellang / EFCore.Sqlite.NodaTime

Licence: MIT License
Adds support for NodaTime types when using SQLite with Entity Framework Core.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to EFCore.Sqlite.NodaTime

Sqlitecodefirst
Creates a SQLite Database based on a EdmModel by using Entity Framework CodeFirst.
Stars: ✭ 526 (+2404.76%)
Mutual labels:  sqlite, entity-framework
sqlite-dotnet-core
.NET Core 2.1 Console Application using SQLite with Entity Framework and Dependency Injection
Stars: ✭ 17 (-19.05%)
Mutual labels:  sqlite, entity-framework
Sqlcetoolbox
SQLite & SQL Server Compact Toolbox extension for Visual Studio, SSMS (and stand alone)
Stars: ✭ 651 (+3000%)
Mutual labels:  sqlite, entity-framework
Entityframework.exceptions
Handle database errors easily when working with Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql
Stars: ✭ 266 (+1166.67%)
Mutual labels:  sqlite, entity-framework
Entityworker.core
EntityWorker is an object-relation mapper(ORM) that enable .NET developers to work with relations data using objects. EntityWorker is an alternative to entityframwork. is more flexible and much faster than entity framework.
Stars: ✭ 91 (+333.33%)
Mutual labels:  sqlite, entity-framework
database
Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
Stars: ✭ 25 (+19.05%)
Mutual labels:  sqlite
HighLite
An SQLite ORM for Android with automatic database migrations built with annotation processing
Stars: ✭ 77 (+266.67%)
Mutual labels:  sqlite
Ionic-2-sqlite-demo
Simple demo to show how to work with Sqlite Storage in Ionic 2
Stars: ✭ 20 (-4.76%)
Mutual labels:  sqlite
SpeedTest-php
a speedtest php site
Stars: ✭ 28 (+33.33%)
Mutual labels:  sqlite
react-native-quick-sqlite
Fast SQLite for react-native.
Stars: ✭ 239 (+1038.1%)
Mutual labels:  sqlite
couchwarehouse
Data warehouse for CouchDB
Stars: ✭ 41 (+95.24%)
Mutual labels:  sqlite
acid-store
A library for secure, deduplicated, transactional, and verifiable data storage
Stars: ✭ 48 (+128.57%)
Mutual labels:  sqlite
sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (+42.86%)
Mutual labels:  sqlite
winmerge2011
Fork of WinMerge which has a different set of features
Stars: ✭ 36 (+71.43%)
Mutual labels:  sqlite
microlight
A fully IndieWeb-compatible PHP blogging engine
Stars: ✭ 35 (+66.67%)
Mutual labels:  sqlite
sqlite-amalgamation
The SQLite amalgamation mirror with cmake
Stars: ✭ 72 (+242.86%)
Mutual labels:  sqlite
recognition-text
A recognition-text application which recognize any text from an image with 98% to 100% accuracy. Gave support for 92 languages and translate your recognized text to 6 supported languages.
Stars: ✭ 22 (+4.76%)
Mutual labels:  sqlite
reactnative-typescript
Playground and evolution of learnings done in react native with typescript
Stars: ✭ 28 (+33.33%)
Mutual labels:  sqlite
astro
Astro allows rapid and clean development of {Extract, Load, Transform} workflows using Python and SQL, powered by Apache Airflow.
Stars: ✭ 79 (+276.19%)
Mutual labels:  sqlite
closql
Store EIEIO objects using EmacSQL
Stars: ✭ 23 (+9.52%)
Mutual labels:  sqlite

EFCore.Sqlite.NodaTime

Build

Adds support for NodaTime types when using SQLite with Entity Framework Core.

Installation

NuGet

Install the latest package from NuGet.

Getting Started

If you're using Entity Framework Core without Dependency Injection, you can call UseNodaTime inside the OnConfiguring method in your DbContext class:

public class MyDbContext : DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlite("<connection-string>", x => x.UseNodaTime());
    }
}

Otherwise, you should call UseNodaTime when adding the DbContext to your service collection:

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<MyDbContext>(options =>
            options.UseSqlite("<connection-string>", x => x.UseNodaTime()));
    }
}

And that's it. You can now use NodaTime types in your entities and perform server-side queries on them!

Supported Types

The following NodaTime types are currently supported:

NodaTime Type SQLite Type SQLite Format
Instant TEXT YYYY-MM-DD HH:MM:SS.SSS
LocalDateTime TEXT YYYY-MM-DD HH:MM:SS.SSS
LocalDate TEXT YYYY-MM-DD
LocalTime TEXT HH:MM:SS.SSS

Supported Properties

NodaTime Property Generated SQL Notes
Year strftime('%Y', <column>) The value is cast to INTEGER for comparison.
Month strftime('%m', <column>) The value is cast to INTEGER for comparison.
Day strftime('%d', <column>) The value is cast to INTEGER for comparison.
Hour strftime('%H', <column>) The value is cast to INTEGER for comparison.
Minute strftime('%M', <column>) The value is cast to INTEGER for comparison.
Second strftime('%S', <column>) The value is cast to INTEGER for comparison.
DayOfYear strftime('%j', <column>) The value is cast to INTEGER for comparison.
DayOfWeek strftime('%w', <column>) The value is cast to INTEGER for comparison. As NodaTime's IsoDayOfWeek enum doesn't match SQLite's day of week, additional SQL is emitted to convert Sunday to the correct value.
Date date(<column>)
TimeOfDay strftime('%H:%M:%f', <column>) In order to support fractional seconds to fully roundtrip LocalTime, a custom format string is used instead of using time(<column>).

Supported Methods

NodaTime Method Generated SQL
SystemClock.Instance.GetCurrentInstant() strftime('%Y-%m-%d %H:%M:%f', 'now')
LocalDate.PlusYears date(<column>, '+n years')
LocalDate.PlusMonths date(<column>, '+n months')
LocalDate.PlusWeeks date(<column>, '+n*7 days')
LocalDate.PlusDays date(<column>, '+n days')
LocalTime.PlusHours strftime('%H:%M:%f', <column>, '+n hours')
LocalTime.PlusMinutes strftime('%H:%M:%f', <column>, '+n minutes')
LocalTime.PlusSeconds strftime('%H:%M:%f', <column>, '+n seconds')
LocalTime.PlusMilliseconds strftime('%H:%M:%f', <column>, '+0.n seconds')
LocalDateTime.PlusYears strftime('%Y-%m-%d %H:%M:%f',<column>, '+n years')
LocalDateTime.PlusMonths strftime('%Y-%m-%d %H:%M:%f',<column>, '+n months')
LocalDateTime.PlusWeeks strftime('%Y-%m-%d %H:%M:%f',<column>, '+n*7 days')
LocalDateTime.PlusDays strftime('%Y-%m-%d %H:%M:%f',<column>, '+n days')
LocalDateTime.PlusHours strftime('%Y-%m-%d %H:%M:%f', <column>, '+n hours')
LocalDateTime.PlusMinutes strftime('%Y-%m-%d %H:%M:%f', <column>, '+n minutes')
LocalDateTime.PlusSeconds strftime('%Y-%m-%d %H:%M:%f', <column>, '+n seconds')
LocalDateTime.PlusMilliseconds strftime('%Y-%m-%d %H:%M:%f', <column>, '+0.n seconds')

When these methods are chained, all modifiers will be added to the same function call, like this:

context.NodaTime.Select(x => x.LocalDateTime.PlusMonths(2).PlusDays(2).PlusHours(2).PlusSeconds(2))

Results in the following SQL:

SELECT strftime('%Y-%m-%d %H:%M:%f', "n"."LocalDateTime", '+2 months', '+2 days', '+2 hours', '+2 seconds')
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].