forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLiteConnection.cs
More file actions
60 lines (50 loc) · 2.23 KB
/
Copy pathSQLiteConnection.cs
File metadata and controls
60 lines (50 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Data.Common;
using JetBrains.Annotations;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Relational;
using Microsoft.Data.Entity.Utilities;
using Microsoft.Data.SQLite;
using Microsoft.Framework.Logging;
namespace Microsoft.Data.Entity.SQLite
{
public class SQLiteConnection : RelationalConnection
{
/// <summary>
/// This constructor is intended only for use when creating test doubles that will override members
/// with mocked or faked behavior. Use of this constructor for other purposes may result in unexpected
/// behavior including but not limited to throwing <see cref="NullReferenceException" />.
/// </summary>
protected SQLiteConnection()
{
}
public SQLiteConnection([NotNull] LazyRef<IDbContextOptions> options, [NotNull] ILoggerFactory loggerFactory)
: base(options, loggerFactory)
{
}
protected override DbConnection CreateDbConnection()
{
return new Data.SQLite.SQLiteConnection(ConnectionString);
}
public virtual Data.SQLite.SQLiteConnection CreateConnectionReadWriteCreate()
{
// TODO: Handle uris
var builder = new SQLiteConnectionStringBuilder(ConnectionString) { Mode = "RWC" };
return new Data.SQLite.SQLiteConnection(builder.ConnectionString);
}
public virtual Data.SQLite.SQLiteConnection CreateConnectionReadWrite()
{
// TODO: Handle in-memory & uris
var builder = new SQLiteConnectionStringBuilder(ConnectionString) { Mode = "RW" };
return new Data.SQLite.SQLiteConnection(builder.ConnectionString);
}
public virtual Data.SQLite.SQLiteConnection CreateConnectionReadOnly()
{
// TODO: Handle in-memory & uris
var builder = new SQLiteConnectionStringBuilder(ConnectionString) { Mode = "RO" };
return new Data.SQLite.SQLiteConnection(builder.ConnectionString);
}
}
}