@@ -20,7 +20,7 @@ public class NotNullConstraintViolationException : SQLiteException {
2020 public NotNullConstraintViolationException ( SQLite3 . Result result , string message , TableMapping ? mapping , object ? obj )
2121 : base ( result , message ) {
2222 if ( mapping is not null && obj is not null ) {
23- Columns = mapping . Columns . Where ( column => ! column . IsNullable && column . GetValue ( obj ) is null ) ;
23+ Columns = mapping . Columns . Where ( column => column . NotNull && column . GetValue ( obj ) is null ) ;
2424 }
2525 }
2626 public NotNullConstraintViolationException ( SQLite3 . Result result , string message )
@@ -46,7 +46,7 @@ public enum SQLiteOpenFlags {
4646[ Flags ]
4747public enum CreateFlags {
4848 /// <summary>
49- /// Use the default creation options
49+ /// Use the default creation options.
5050 /// </summary>
5151 None = 0x000 ,
5252 /// <summary>
@@ -59,22 +59,21 @@ public enum CreateFlags {
5959 /// </summary>
6060 ImplicitIndex = 0x002 ,
6161 /// <summary>
62- /// Create a primary key for a property called 'Id' and
63- /// create an indices for properties ending in 'Id' (case-insensitive).
62+ /// Create a primary key for a property called 'Id' and create indices for properties ending in 'Id' (case-insensitive).
6463 /// </summary>
65- AllImplicit = 0x003 ,
64+ AllImplicit = ImplicitPrimaryKey | ImplicitIndex ,
6665 /// <summary>
6766 /// Force the primary key property to be auto incrementing.
68- /// This avoids the need for the [AutoIncrement] attribute .
69- /// The primary key property on the class should have type int or long.
67+ /// This avoids the need for [<see cref="AutoIncrementAttribute"/>] .
68+ /// The primary key property type should be <see cref=" int"/> or <see cref=" long"/> .
7069 /// </summary>
7170 AutoIncrementPrimaryKey = 0x004 ,
7271 /// <summary>
73- /// Create virtual table using FTS3
72+ /// Create a virtual table using FTS3.
7473 /// </summary>
7574 FullTextSearch3 = 0x100 ,
7675 /// <summary>
77- /// Create virtual table using FTS4
76+ /// Create a virtual table using FTS4.
7877 /// </summary>
7978 FullTextSearch4 = 0x200
8079}
@@ -105,7 +104,7 @@ public interface ISQLiteConnection : IDisposable {
105104 int CreateIndex < T > ( Expression < Func < T , object > > property , bool unique = false ) ;
106105 CreateTableResult CreateTable < T > ( CreateFlags createFlags = CreateFlags . None ) ;
107106 CreateTableResult CreateTable ( Type type , CreateFlags createFlags = CreateFlags . None ) ;
108- CreateTablesResult CreateTables ( CreateFlags createFlags = CreateFlags . None , params IEnumerable < Type > types ) ;
107+ CreateTablesResult CreateTables ( IEnumerable < Type > types , CreateFlags createFlags = CreateFlags . None ) ;
109108 IEnumerable < T > DeferredQuery < T > ( string query , params IEnumerable < object ? > parameters ) where T : new ( ) ;
110109 IEnumerable < object > DeferredQuery ( TableMapping map , string query , params IEnumerable < object ? > parameters ) ;
111110 int Delete ( object objectToDelete ) ;
@@ -530,7 +529,7 @@ public CreateTableResult CreateTable(Type type, CreateFlags createFlags = Create
530529 /// <returns>
531530 /// Whether the table was created or migrated for each type.
532531 /// </returns>
533- public CreateTablesResult CreateTables ( CreateFlags createFlags = CreateFlags . None , params IEnumerable < Type > types ) {
532+ public CreateTablesResult CreateTables ( IEnumerable < Type > types , CreateFlags createFlags = CreateFlags . None ) {
534533 CreateTablesResult result = new ( ) ;
535534 foreach ( Type type in types ) {
536535 CreateTableResult oneResult = CreateTable ( type , createFlags ) ;
@@ -1261,7 +1260,7 @@ public int Insert(object obj, string? modifier = null) {
12611260
12621261 TableMapping map = GetMapping ( obj . GetType ( ) ) ;
12631262
1264- if ( map . PrimaryKey is not null && map . PrimaryKey . IsAutoGuid ) {
1263+ if ( map . PrimaryKey is not null && map . PrimaryKey . AutoGuid ) {
12651264 if ( Equals ( map . PrimaryKey . GetValue ( obj ) , Guid . Empty ) ) {
12661265 map . PrimaryKey . SetValue ( obj , Guid . NewGuid ( ) ) ;
12671266 }
@@ -1554,22 +1553,6 @@ public int Delete(object primaryKey, TableMapping map) {
15541553 return count ;
15551554 }
15561555
1557- /// <summary>
1558- /// Deletes all the objects from the specified table.
1559- /// WARNING WARNING: Let me repeat. It deletes ALL the objects from the
1560- /// specified table. Do you really want to do that?
1561- /// </summary>
1562- /// <returns>
1563- /// The number of objects deleted.
1564- /// </returns>
1565- /// <typeparam name='T'>
1566- /// The type of objects to delete.
1567- /// </typeparam>
1568- public int DeleteAll < T > ( ) {
1569- TableMapping map = GetMapping < T > ( ) ;
1570- return DeleteAll ( map ) ;
1571- }
1572-
15731556 /// <summary>
15741557 /// Deletes all the objects from the specified table.<br/>
15751558 /// WARNING: To be clear, it deletes ALL the objects from the specified table. Do you really want that?
@@ -1587,6 +1570,10 @@ public int DeleteAll(TableMapping map) {
15871570 OnTableChanged ( map , NotifyTableChangedAction . Delete ) ;
15881571 return count ;
15891572 }
1573+ /// <inheritdoc cref="DeleteAll(TableMapping)"/>
1574+ public int DeleteAll < T > ( ) {
1575+ return DeleteAll ( GetMapping < T > ( ) ) ;
1576+ }
15901577
15911578 /// <summary>
15921579 /// Backup the entire database to the specified path.
@@ -1850,10 +1837,10 @@ public TableMapping(Type type, CreateFlags createFlags = CreateFlags.None) {
18501837 }
18511838 Columns = [ .. columns ] ;
18521839 foreach ( Column column in Columns ) {
1853- if ( column . IsAutoIncrement && column . IsPrimaryKey ) {
1840+ if ( column . AutoIncrement && column . PrimaryKey ) {
18541841 _autoIncrementedPrimaryKey = column ;
18551842 }
1856- if ( column . IsPrimaryKey ) {
1843+ if ( column . PrimaryKey ) {
18571844 PrimaryKey = column ;
18581845 }
18591846 }
@@ -1888,13 +1875,13 @@ public class Column {
18881875 public string PropertyName { get => _memberInfo . Name ; }
18891876 public Type ColumnType { get ; }
18901877 public string Collation { get ; }
1891- public bool IsAutoIncrement { get ; }
1892- public bool IsAutoGuid { get ; }
1893- public bool IsPrimaryKey { get ; }
1894- public IEnumerable < IndexedAttribute > Indices { get ; }
1895- public bool IsNullable { get ; }
1878+ public bool AutoIncrement { get ; }
1879+ public bool AutoGuid { get ; }
1880+ public bool PrimaryKey { get ; }
1881+ public bool NotNull { get ; }
18961882 public int ? MaxStringLength { get ; }
18971883 public bool StoreAsText { get ; }
1884+ public IEnumerable < IndexedAttribute > Indices { get ; }
18981885
18991886 private readonly MemberInfo _memberInfo ;
19001887
@@ -1908,18 +1895,18 @@ public Column(MemberInfo member, CreateFlags createFlags = CreateFlags.None) {
19081895 ColumnType = Nullable . GetUnderlyingType ( memberType ) ?? memberType ;
19091896 Collation = Orm . GetCollation ( member ) ;
19101897
1911- IsPrimaryKey = Orm . IsPrimaryKey ( member )
1898+ PrimaryKey = Orm . IsPrimaryKey ( member )
19121899 || ( createFlags . HasFlag ( CreateFlags . ImplicitPrimaryKey ) && string . Equals ( member . Name , Orm . ImplicitPrimaryKeyName , StringComparison . OrdinalIgnoreCase ) ) ;
19131900
1914- bool isAutoIncrement = Orm . IsAutoIncrement ( member ) || ( IsPrimaryKey && ( ( createFlags & CreateFlags . AutoIncrementPrimaryKey ) == CreateFlags . AutoIncrementPrimaryKey ) ) ;
1915- IsAutoGuid = isAutoIncrement && ColumnType == typeof ( Guid ) ;
1916- IsAutoIncrement = isAutoIncrement && ! IsAutoGuid ;
1901+ bool isAutoIncrement = Orm . IsAutoIncrement ( member ) || ( PrimaryKey && ( ( createFlags & CreateFlags . AutoIncrementPrimaryKey ) == CreateFlags . AutoIncrementPrimaryKey ) ) ;
1902+ AutoGuid = isAutoIncrement && ColumnType == typeof ( Guid ) ;
1903+ AutoIncrement = isAutoIncrement && ! AutoGuid ;
19171904
19181905 Indices = Orm . GetIndices ( member ) ;
1919- if ( ! Indices . Any ( ) && ! IsPrimaryKey && createFlags . HasFlag ( CreateFlags . ImplicitIndex ) && Name . EndsWith ( Orm . ImplicitIndexSuffix , StringComparison . OrdinalIgnoreCase ) ) {
1906+ if ( ! Indices . Any ( ) && ! PrimaryKey && createFlags . HasFlag ( CreateFlags . ImplicitIndex ) && Name . EndsWith ( Orm . ImplicitIndexSuffix , StringComparison . OrdinalIgnoreCase ) ) {
19201907 Indices = [ new IndexedAttribute ( ) ] ;
19211908 }
1922- IsNullable = ! ( IsPrimaryKey || Orm . IsMarkedNotNull ( member ) ) ;
1909+ NotNull = PrimaryKey || Orm . IsMarkedNotNull ( member ) ;
19231910 MaxStringLength = Orm . MaxStringLength ( member ) ;
19241911
19251912 StoreAsText = memberType . GetCustomAttribute < StoreAsTextAttribute > ( ) is not null ;
@@ -1979,13 +1966,13 @@ public static class Orm {
19791966 public static string SqlDecl ( TableMapping . Column column ) {
19801967 string decl = $ "\" { column . Name } \" { SqlType ( column ) } ";
19811968
1982- if ( column . IsPrimaryKey ) {
1969+ if ( column . PrimaryKey ) {
19831970 decl += "primary key " ;
19841971 }
1985- if ( column . IsAutoIncrement ) {
1972+ if ( column . AutoIncrement ) {
19861973 decl += "autoincrement " ;
19871974 }
1988- if ( ! column . IsNullable ) {
1975+ if ( column . NotNull ) {
19891976 decl += "not null " ;
19901977 }
19911978 if ( ! string . IsNullOrEmpty ( column . Collation ) ) {
@@ -2720,8 +2707,8 @@ public int Delete(Expression<Func<T, bool>>? predicateExpression) {
27202707 string commandText = $ "delete from \" { Table . TableName } \" where { CompileExpression ( predicate ! , parameters ) . CommandText } ";
27212708 SQLiteCommand command = Connection . CreateCommand ( commandText , parameters ) ;
27222709
2723- int result = command . ExecuteNonQuery ( ) ;
2724- return result ;
2710+ int rowCount = command . ExecuteNonQuery ( ) ;
2711+ return rowCount ;
27252712 }
27262713
27272714 /// <summary>
0 commit comments