Skip to content
New issue

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

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

Already on GitHub? # to your account

Extracted IDatabase for mocking, added the ability to set case sensit… #29

Merged
merged 1 commit into from
Aug 12, 2016
Merged
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
2,319 changes: 1,749 additions & 570 deletions AsyncPoco/AsyncPoco.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions AsyncPoco/AsyncPoco.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Compile Include="DatabaseTypes\SqlServerDatabaseType.cs" />
<Compile Include="DatabaseTypes\SqlServerCEDatabaseType.cs" />
<Compile Include="DatabaseTypes\MySqlDatabaseType.cs" />
<Compile Include="IDatabase.cs" />
<Compile Include="Utilities\AutoSelectHelper.cs" />
<Compile Include="Utilities\PagingHelper.cs" />
<Compile Include="Utilities\ParametersHelper.cs" />
Expand Down
4 changes: 3 additions & 1 deletion AsyncPoco/Core/MultiPocoFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace AsyncPoco.Internal
{
class MultiPocoFactory
{
public static IEqualityComparer<string> FieldNameComparer { get; set; } = StringComparer.InvariantCultureIgnoreCase;

// Instance data used by the Multipoco factory delegate - essentially a list of the nested poco factories to call
List<Delegate> _delegates;
public Delegate GetItem(int index) { return _delegates[index]; }
Expand Down Expand Up @@ -75,7 +77,7 @@ static Delegate FindSplitPoint(Type typeThis, Type typeNext, string ConnectionSt

// Find split point
int firstColumn = pos;
var usedColumns = new Dictionary<string, bool>();
var usedColumns = new Dictionary<string, bool>(FieldNameComparer);
for (; pos < r.FieldCount; pos++)
{
// Split if field name has already been used, or if the field doesn't exist in current poco but does in the next
Expand Down
9 changes: 5 additions & 4 deletions AsyncPoco/Core/PocoData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace AsyncPoco.Internal
{
class PocoData
{
public static IEqualityComparer<string> ColumnComparer { get;set;}=StringComparer.InvariantCultureIgnoreCase;

public static PocoData ForObject(object o, string primaryKeyName)
{
var t = o.GetType();
Expand All @@ -22,7 +24,7 @@ public static PocoData ForObject(object o, string primaryKeyName)
{
var pd = new PocoData();
pd.TableInfo = new TableInfo();
pd.Columns = new Dictionary<string, PocoColumn>(StringComparer.OrdinalIgnoreCase);
pd.Columns = new Dictionary<string, PocoColumn>(ColumnComparer);
pd.Columns.Add(primaryKeyName, new ExpandoColumn() { ColumnName = primaryKeyName });
pd.TableInfo.PrimaryKey = primaryKeyName;
pd.TableInfo.AutoIncrement = true;
Expand Down Expand Up @@ -63,7 +65,7 @@ public PocoData(Type t)
TableInfo = mapper.GetTableInfo(t);

// Work out bound properties
Columns = new Dictionary<string, PocoColumn>(StringComparer.OrdinalIgnoreCase);
Columns = new Dictionary<string, PocoColumn>(ColumnComparer);
foreach (var pi in t.GetProperties())
{
ColumnInfo ci = mapper.GetColumnInfo(pi);
Expand Down Expand Up @@ -116,7 +118,6 @@ public Delegate GetFactory(string sql, string connString, int firstColumn, int c
#if !PETAPOCO_NO_DYNAMIC
if (type == typeof(object))
{
// var poco=new T()
il.Emit(OpCodes.Newobj, typeof(System.Dynamic.ExpandoObject).GetConstructor(Type.EmptyTypes)); // obj

MethodInfo fnAdd = typeof(IDictionary<string, object>).GetMethod("Add");
Expand Down Expand Up @@ -251,7 +252,7 @@ public Delegate GetFactory(string sql, string connString, int firstColumn, int c
{
il.Emit(OpCodes.Newobj, dstType.GetConstructor(new Type[] { Nullable.GetUnderlyingType(dstType) }));
}

il.Emit(OpCodes.Callvirt, pc.PropertyInfo.GetSetMethod(true)); // poco
Handled = true;
}
Expand Down
Loading