Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderBy RANDOM(), Column selection, IEnumerable.Select handling in Where Expression, ... #319

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/SQLite.Net/Attributes/DefaultColumnInformationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ public class DefaultColumnInformationProvider : IColumnInformationProvider

public string GetColumnName(PropertyInfo p)
{
var colAttr = p.GetCustomAttributes<ColumnAttribute>(true).FirstOrDefault();
var colAttr =
p.GetCustomAttributes<ColumnAttribute>(true).FirstOrDefault();
return colAttr == null ? p.Name : colAttr.Name;
}

public bool IsIgnored(PropertyInfo p)
public string GetTableName(TypeInfo t)
{
var tableAttr =
t.GetCustomAttributes<TableAttribute>(true).FirstOrDefault();
return tableAttr == null ? t.Name : tableAttr.Name;
}

public bool IsIgnored(PropertyInfo p)
{
return p.IsDefined(typeof (IgnoreAttribute), true);
}
Expand Down
1 change: 1 addition & 0 deletions src/SQLite.Net/Attributes/IColumnInformationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public interface IColumnInformationProvider
bool IsMarkedNotNull(MemberInfo p);
bool IsIgnored(PropertyInfo p);
string GetColumnName(PropertyInfo p);
string GetTableName(TypeInfo t);
}
}

6 changes: 6 additions & 0 deletions src/SQLite.Net/PreparedSqlLiteInsertCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ public int ExecuteNonQuery(object[] source)
sqlitePlatform.SQLiteApi.Reset(Statement);
throw NotNullConstraintViolationException.New(r, sqlitePlatform.SQLiteApi.Errmsg16(Connection.Handle));
}

else if (r == Result.Constraint)
{
sqlitePlatform.SQLiteApi.Reset(Statement);
throw SQLiteException.New(r, sqlitePlatform.SQLiteApi.Errmsg16(Connection.Handle));
}
sqlitePlatform.SQLiteApi.Reset(Statement);

throw SQLiteException.New(r, r.ToString());
Expand Down
5 changes: 1 addition & 4 deletions src/SQLite.Net/TableMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ public TableMapping(Type type, IEnumerable<PropertyInfo> properties, CreateFlags
}

MappedType = type;

var tableAttr = type.GetTypeInfo().GetCustomAttributes<TableAttribute>().FirstOrDefault();

TableName = tableAttr != null ? tableAttr.Name : MappedType.Name;
TableName = infoProvider.GetTableName(MappedType.GetTypeInfo());

var props = properties;

Expand Down
Loading