Skip to content

Commit 890b4cf

Browse files
committed
remove more old sqlite tests. Make TableQuery internal for now until the design can be more thoroughly thought out. Remove Binding a table statement with an object of type T
1 parent 76ce0b5 commit 890b4cf

9 files changed

Lines changed: 69 additions & 559 deletions

File tree

SQLitePCL.pretty.Orm/Interfaces.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public interface ITableMapping
1313
/// </summary>
1414
String TableName { get; }
1515

16+
/// <summary>
17+
/// Gets the table columns.
18+
/// </summary>
1619
IReadOnlyDictionary<string, ColumnMapping> Columns { get; }
1720

1821
/// <summary>

SQLitePCL.pretty.Orm/TableMappedStatement.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ namespace SQLitePCL.pretty.Orm
1010
/// </summary>
1111
public static class TableMappedStatement
1212
{
13+
/*
1314
/// <summary>
1415
/// Binds the statement bind variables by name to the corresponding properties on the object <paramref name="obj"/>.
1516
/// </summary>
1617
/// <param name="This">The statement.</param>
1718
/// <param name="obj">The object to bind.</param>
1819
/// <typeparam name="T">The mapped type.</typeparam>
19-
public static void Bind<T>(this ITableMappedStatement<T> This, T obj)
20+
static void Bind<T>(this ITableMappedStatement<T> This, T obj)
2021
{
2122
This.Bind(This.Mapping, obj);
2223
}
@@ -38,7 +39,7 @@ public static void Execute<T>(this ITableMappedStatement<T> This, T obj)
3839
This.ClearBindings();
3940
This.Bind(obj);
4041
This.MoveNext();
41-
}
42+
}*/
4243

4344
private static IEnumerator<T> Enumerate<T>(this ITableMappedStatement<T> This)
4445
{

SQLitePCL.pretty.Orm/TableMapping.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ internal static void Bind<T>(this IStatement This, ITableMapping<T> tableMapping
4949
}
5050
}
5151

52-
public static TableQuery<T> Query<T>(this ITableMapping<T> This)
52+
internal static TableQuery<T> Query<T>(this ITableMapping<T> This)
5353
{
5454
return new TableQuery<T>(This, "*", null, new List<Ordering>(), null, null);
5555
}

SQLitePCL.pretty.Orm/TableQuery.cs

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System;
2525
using System.Collections;
2626
using System.Collections.Generic;
27+
using System.Diagnostics.Contracts;
2728
using System.Linq;
2829
using System.Linq.Expressions;
2930
using System.Reactive.Linq;
@@ -37,11 +38,10 @@
3738

3839
namespace SQLitePCL.pretty.Orm
3940
{
40-
4141
/// <summary>
4242
/// An immutable builder that allows the use of LINQ like syntax to build a SQL query that can subsequently be executed against a SQLite database.
4343
/// </summary>
44-
public sealed class TableQuery<T>
44+
internal sealed class TableQuery<T>
4545
{
4646
private readonly string _selection;
4747
private readonly ITableMapping<T> _mapping;
@@ -106,9 +106,9 @@ public override string ToString()
106106
/// Converts the query to a count query.
107107
/// </summary>
108108
/// <returns>A new <see cref="SQLitePCL.pretty.Orm.TableQuery&lt;T&gt;"/>.</returns>
109-
public TableQuery<T> Count()
109+
public string Count()
110110
{
111-
return new TableQuery<T>(_mapping, "count(*)", _where, _orderBy, _limit, _offset);
111+
return new TableQuery<T>(_mapping, "count(*)", _where, _orderBy, _limit, _offset).ToString();
112112
}
113113

114114
/// <summary>
@@ -125,7 +125,6 @@ public TableQuery<T> Where(Expression<Func<T, bool>> predExpr)
125125

126126
if (_limit != null || _offset != null)
127127
{
128-
// FIXME: Why?
129128
throw new NotSupportedException("Cannot call where after a skip or a take");
130129
}
131130

@@ -467,7 +466,7 @@ private static string GetSqlName (Expression expr)
467466
/// <summary>
468467
/// Extension methods for querying a database using instances of <see cref="TableQuery&lt;T&gt;"/>
469468
/// </summary>
470-
public static class TableQuery
469+
internal static class TableQuery
471470
{
472471
public static ITableMappedStatement<T> PrepareStatement<T>(this IDatabaseConnection This, TableQuery<T> query)
473472
{
@@ -489,44 +488,14 @@ public static IObservable<T> Query<T>(this IAsyncDatabaseConnection This, TableQ
489488
return This.Query(query.ToString()).Select(query.Mapping.ToObject);
490489
}
491490

492-
public static IStatement PrepareCountStatement<T>(this IDatabaseConnection This, TableQuery<T> query)
493-
{
494-
return This.PrepareStatement(query.Count().ToString());
495-
}
496-
497-
public static Task<IAsyncStatement> PrepareCountStatemenAsync<T>(this IAsyncDatabaseConnection This, TableQuery<T> query)
498-
{
499-
return This.PrepareStatementAsync(query.Count().ToString());
500-
}
501-
502-
public static int Count<T>(this IDatabaseConnection This, TableQuery<T> query)
503-
{
504-
return This.Query(query.Count().ToString()).SelectScalarInt().First();
505-
}
506-
507-
public static Task<int> CountAsync<T>(this IAsyncDatabaseConnection This, TableQuery<T> query)
491+
public static IObservable<T> Query<T>(this IAsyncDatabaseConnection This, TableQuery<T> query, params object[] values)
508492
{
509-
return This.CountAsync(query, CancellationToken.None);
510-
}
511-
512-
public static Task<int> CountAsync<T>(this IAsyncDatabaseConnection This, TableQuery<T> query, CancellationToken ct)
513-
{
514-
return This.Query(query.Count().ToString()).SelectScalarInt().FirstAsync().ToTask(ct);
515-
}
516-
517-
public static int Count<T>(this IDatabaseConnection This, TableQuery<T> query, params object[] values)
518-
{
519-
return This.Query(query.Count().ToString(), values).SelectScalarInt().First();
520-
}
521-
522-
public static Task<int> CountAsync<T>(this IAsyncDatabaseConnection This, TableQuery<T> query, params object[] values)
523-
{
524-
return This.CountAsync(query, CancellationToken.None, values);
493+
return This.Query(query.ToString(), values).Select(query.Mapping.ToObject);
525494
}
526495

527-
public static Task<int> CountAsync<T>(this IAsyncDatabaseConnection This, TableQuery<T> query, CancellationToken ct, params object[] values)
496+
public static IStatement PrepareCountStatement<T>(this IDatabaseConnection This, TableQuery<T> query)
528497
{
529-
return This.Query(query.Count().ToString(), values).SelectScalarInt().FirstAsync().ToTask(ct);
498+
return This.PrepareStatement(query.Count().ToString());
530499
}
531500
}
532501
}

SQLitePCL.pretty.tests/Orm/ByteArrayTests.cs

Lines changed: 0 additions & 106 deletions
This file was deleted.

SQLitePCL.pretty.tests/Orm/GuidTests.cs

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)