This commit is contained in:
@@ -33,30 +33,30 @@
|
|||||||
* * DYNAMORM_OMMIT_TRYPARSE - Remove TryParse helpers (also applies DYNAMORM_OMMIT_GENERICEXECUTION)
|
* * DYNAMORM_OMMIT_TRYPARSE - Remove TryParse helpers (also applies DYNAMORM_OMMIT_GENERICEXECUTION)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.Data;
|
|
||||||
using System.Data.Common;
|
|
||||||
using System.Dynamic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using DynamORM.Builders;
|
|
||||||
using DynamORM.Builders.Extensions;
|
using DynamORM.Builders.Extensions;
|
||||||
using DynamORM.Builders.Implementation;
|
using DynamORM.Builders.Implementation;
|
||||||
using DynamORM.Helpers;
|
using DynamORM.Builders;
|
||||||
using DynamORM.Helpers.Dynamics;
|
using DynamORM.Helpers.Dynamics;
|
||||||
|
using DynamORM.Helpers;
|
||||||
using DynamORM.Mapper;
|
using DynamORM.Mapper;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Data.Common;
|
||||||
|
using System.Data;
|
||||||
|
using System.Dynamic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System;
|
||||||
|
|
||||||
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "This is a generated file which generates all the necessary support classes.")]
|
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "This is a generated file which generates all the necessary support classes.")]
|
||||||
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1403:FileMayOnlyContainASingleNamespace", Justification = "This is a generated file which generates all the necessary support classes.")]
|
[module: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1403:FileMayOnlyContainASingleNamespace", Justification = "This is a generated file which generates all the necessary support classes.")]
|
||||||
|
|
||||||
namespace DynamORM
|
namespace DynamORM
|
||||||
{
|
{
|
||||||
/// <summary>Small utility class to manage single columns.</summary>
|
/// <summary>Small utility class to manage single columns.</summary>
|
||||||
@@ -1222,43 +1222,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchInsert<T>(mapper, cmd, parameters);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Insert<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parameters[cp] = temp[p.Name];
|
|
||||||
parameters[cp].InsertCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
ib.Insert(col, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmd);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.InsertCommandText = cmd.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var o in e)
|
foreach (var o in e)
|
||||||
{
|
{
|
||||||
@@ -1356,48 +1320,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchUpdate<T>(mapper, cmd, parameters);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Update<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parameters[cp] = temp[p.Name];
|
|
||||||
parameters[cp].UpdateCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
{
|
|
||||||
if (currentprop.Column != null && currentprop.Column.IsKey)
|
|
||||||
ib.Where(col, null);
|
|
||||||
else
|
|
||||||
ib.Values(col, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmd);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.UpdateCommandText = cmd.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var o in e)
|
foreach (var o in e)
|
||||||
{
|
{
|
||||||
@@ -1466,48 +1389,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchUpdate<T>(mapper, cmdUp, parametersUp);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Update<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parametersUp[cp] = temp[p.Name];
|
|
||||||
parametersUp[cp].UpdateCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
{
|
|
||||||
if (currentprop.Column != null && currentprop.Column.IsKey)
|
|
||||||
ib.Where(col, null);
|
|
||||||
else
|
|
||||||
ib.Values(col, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmdUp);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.UpdateCommandText = cmdUp.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Update
|
#endregion Update
|
||||||
|
|
||||||
@@ -1532,43 +1414,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchInsert<T>(mapper, cmdIn, parametersIn);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Insert<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parametersIn[cp] = temp[p.Name];
|
|
||||||
parametersIn[cp].InsertCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
ib.Insert(col, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmdIn);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.InsertCommandText = cmdIn.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Insert
|
#endregion Insert
|
||||||
|
|
||||||
@@ -1669,46 +1515,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchDelete<T>(mapper, cmd, parameters);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Delete<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parameters[cp] = temp[p.Name];
|
|
||||||
parameters[cp].DeleteCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
{
|
|
||||||
if (currentprop.Column != null && currentprop.Column.IsKey)
|
|
||||||
ib.Where(col, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmd);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.DeleteCommandText = cmd.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var o in e)
|
foreach (var o in e)
|
||||||
{
|
{
|
||||||
@@ -1738,6 +1545,190 @@ namespace DynamORM
|
|||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PrepareBatchInsert<T>(DynamicTypeMap mapper, IDbCommand cmd, Dictionary<IDbDataParameter, DynamicPropertyInvoker> parameters)
|
||||||
|
{
|
||||||
|
DynamicPropertyInvoker currentprop = null;
|
||||||
|
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
||||||
|
var schema = this.GetSchema<T>();
|
||||||
|
int ord = 0;
|
||||||
|
|
||||||
|
var ib = Insert<T>()
|
||||||
|
.SetVirtualMode(true)
|
||||||
|
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
||||||
|
.CreateParameterAction((p, cp) =>
|
||||||
|
{
|
||||||
|
parameters[cp] = temp[p.Name];
|
||||||
|
parameters[cp].InsertCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
||||||
|
{
|
||||||
|
Name = cp.ParameterName,
|
||||||
|
Type = cp.DbType,
|
||||||
|
Ordinal = ord++,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var prop in mapper.PropertyMap)
|
||||||
|
if (!mapper.Ignored.Contains(prop.Key))
|
||||||
|
{
|
||||||
|
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
||||||
|
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
||||||
|
|
||||||
|
if (currentprop.Ignore || (currentprop.Column != null && currentprop.Column.IsNoInsert))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (currentprop.Get != null)
|
||||||
|
ib.Insert(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = schema == null ? null : schema.TryGetNullable(col.ToLower()),
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ib.FillCommand(cmd);
|
||||||
|
|
||||||
|
// Cache command
|
||||||
|
mapper.InsertCommandText = cmd.CommandText;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrepareBatchUpdate<T>(DynamicTypeMap mapper, IDbCommand cmd, Dictionary<IDbDataParameter, DynamicPropertyInvoker> parameters)
|
||||||
|
{
|
||||||
|
DynamicPropertyInvoker currentprop = null;
|
||||||
|
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
||||||
|
var schema = this.GetSchema<T>();
|
||||||
|
int ord = 0;
|
||||||
|
|
||||||
|
var ib = Update<T>()
|
||||||
|
.SetVirtualMode(true)
|
||||||
|
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
||||||
|
.CreateParameterAction((p, cp) =>
|
||||||
|
{
|
||||||
|
parameters[cp] = temp[p.Name];
|
||||||
|
parameters[cp].UpdateCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
||||||
|
{
|
||||||
|
Name = cp.ParameterName,
|
||||||
|
Type = cp.DbType,
|
||||||
|
Ordinal = ord++,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var prop in mapper.PropertyMap)
|
||||||
|
if (!mapper.Ignored.Contains(prop.Key))
|
||||||
|
{
|
||||||
|
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
||||||
|
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
||||||
|
|
||||||
|
if (currentprop.Ignore)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (currentprop.Get != null)
|
||||||
|
{
|
||||||
|
var colS = schema == null ? null : schema.TryGetNullable(col.ToLower());
|
||||||
|
|
||||||
|
if (colS.HasValue)
|
||||||
|
{
|
||||||
|
if (colS.Value.IsKey)
|
||||||
|
ib.Where(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
else if (currentprop.Column == null || !currentprop.Column.IsNoUpdate)
|
||||||
|
ib.Values(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (currentprop.Column != null && currentprop.Column.IsKey)
|
||||||
|
ib.Where(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ib.FillCommand(cmd);
|
||||||
|
|
||||||
|
// Cache command
|
||||||
|
mapper.UpdateCommandText = cmd.CommandText;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrepareBatchDelete<T>(DynamicTypeMap mapper, IDbCommand cmd, Dictionary<IDbDataParameter, DynamicPropertyInvoker> parameters)
|
||||||
|
{
|
||||||
|
DynamicPropertyInvoker currentprop = null;
|
||||||
|
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
||||||
|
var schema = this.GetSchema<T>();
|
||||||
|
int ord = 0;
|
||||||
|
|
||||||
|
var ib = Delete<T>()
|
||||||
|
.SetVirtualMode(true)
|
||||||
|
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
||||||
|
.CreateParameterAction((p, cp) =>
|
||||||
|
{
|
||||||
|
parameters[cp] = temp[p.Name];
|
||||||
|
parameters[cp].DeleteCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
||||||
|
{
|
||||||
|
Name = cp.ParameterName,
|
||||||
|
Type = cp.DbType,
|
||||||
|
Ordinal = ord++,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var prop in mapper.PropertyMap)
|
||||||
|
if (!mapper.Ignored.Contains(prop.Key))
|
||||||
|
{
|
||||||
|
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
||||||
|
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
||||||
|
|
||||||
|
if (currentprop.Ignore)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (currentprop.Get != null)
|
||||||
|
{
|
||||||
|
var colS = schema == null ? null : schema.TryGetNullable(col.ToLower());
|
||||||
|
|
||||||
|
if (colS != null)
|
||||||
|
{
|
||||||
|
if (colS.Value.IsKey)
|
||||||
|
ib.Where(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (currentprop.Column != null && currentprop.Column.IsKey)
|
||||||
|
ib.Where(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ib.FillCommand(cmd);
|
||||||
|
|
||||||
|
// Cache command
|
||||||
|
mapper.DeleteCommandText = cmd.CommandText;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion From/Insert/Update/Delete
|
#endregion From/Insert/Update/Delete
|
||||||
|
|
||||||
#region Schema
|
#region Schema
|
||||||
@@ -1768,7 +1759,7 @@ namespace DynamORM
|
|||||||
Dictionary<string, DynamicSchemaColumn> schema = null;
|
Dictionary<string, DynamicSchemaColumn> schema = null;
|
||||||
|
|
||||||
lock (SyncLock)
|
lock (SyncLock)
|
||||||
schema = Schema.TryGetValue(typeof(T).GetType().FullName) ??
|
schema = Schema.TryGetValue(typeof(T).FullName) ??
|
||||||
BuildAndCacheSchema(null, DynamicMapperCache.GetMapper<T>());
|
BuildAndCacheSchema(null, DynamicMapperCache.GetMapper<T>());
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
@@ -4280,7 +4271,8 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var name = info.ArgumentNames[i].ToLower();
|
var fullName = info.ArgumentNames[i];
|
||||||
|
var name = fullName.ToLower();
|
||||||
|
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
@@ -4301,7 +4293,7 @@ namespace DynamORM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
builder.Insert(name, args[i]);
|
builder.Insert(fullName, args[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4326,7 +4318,8 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var name = info.ArgumentNames[i].ToLower();
|
var fullName = info.ArgumentNames[i];
|
||||||
|
var name = fullName.ToLower();
|
||||||
|
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
@@ -4355,7 +4348,7 @@ namespace DynamORM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
builder.Update(name, args[i]);
|
builder.Update(fullName, args[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4380,7 +4373,8 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var name = info.ArgumentNames[i].ToLower();
|
var fullName = info.ArgumentNames[i];
|
||||||
|
var name = fullName.ToLower();
|
||||||
|
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
@@ -4405,7 +4399,7 @@ namespace DynamORM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
builder.Where(name, args[i]);
|
builder.Where(fullName, args[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4431,7 +4425,8 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var name = info.ArgumentNames[i].ToLower();
|
var fullName = info.ArgumentNames[i];
|
||||||
|
var name = fullName.ToLower();
|
||||||
|
|
||||||
// TODO: Make this nicer
|
// TODO: Make this nicer
|
||||||
switch (name)
|
switch (name)
|
||||||
@@ -4506,7 +4501,7 @@ namespace DynamORM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
builder.Where(name, args[i]);
|
builder.Where(fullName, args[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4808,6 +4803,7 @@ namespace DynamORM
|
|||||||
IDynamicDeleteQueryBuilder Where(object conditions, bool schema = false);
|
IDynamicDeleteQueryBuilder Where(object conditions, bool schema = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Dynamic insert query builder interface.</summary>
|
/// <summary>Dynamic insert query builder interface.</summary>
|
||||||
/// <remarks>This interface it publically available. Implementation should be hidden.</remarks>
|
/// <remarks>This interface it publically available. Implementation should be hidden.</remarks>
|
||||||
public interface IDynamicInsertQueryBuilder : IDynamicQueryBuilder
|
public interface IDynamicInsertQueryBuilder : IDynamicQueryBuilder
|
||||||
@@ -4839,6 +4835,7 @@ namespace DynamORM
|
|||||||
IDynamicInsertQueryBuilder Insert(object o);
|
IDynamicInsertQueryBuilder Insert(object o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Dynamic query builder base interface.</summary>
|
/// <summary>Dynamic query builder base interface.</summary>
|
||||||
/// <remarks>This interface it publically available. Implementation should be hidden.</remarks>
|
/// <remarks>This interface it publically available. Implementation should be hidden.</remarks>
|
||||||
public interface IDynamicQueryBuilder
|
public interface IDynamicQueryBuilder
|
||||||
@@ -4879,6 +4876,7 @@ namespace DynamORM
|
|||||||
Action<IParameter, IDbDataParameter> OnCreateParameter { get; set; }
|
Action<IParameter, IDbDataParameter> OnCreateParameter { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Dynamic select query builder interface.</summary>
|
/// <summary>Dynamic select query builder interface.</summary>
|
||||||
/// <remarks>This interface it publically available. Implementation should be hidden.</remarks>
|
/// <remarks>This interface it publically available. Implementation should be hidden.</remarks>
|
||||||
public interface IDynamicSelectQueryBuilder : IDynamicQueryBuilder ////, IEnumerable<object>
|
public interface IDynamicSelectQueryBuilder : IDynamicQueryBuilder ////, IEnumerable<object>
|
||||||
@@ -5082,6 +5080,7 @@ namespace DynamORM
|
|||||||
#endregion Top/Limit/Offset/Distinct
|
#endregion Top/Limit/Offset/Distinct
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Dynamic update query builder interface.</summary>
|
/// <summary>Dynamic update query builder interface.</summary>
|
||||||
/// <remarks>This interface it publically available. Implementation should be hidden.</remarks>
|
/// <remarks>This interface it publically available. Implementation should be hidden.</remarks>
|
||||||
public interface IDynamicUpdateQueryBuilder : IDynamicQueryBuilder
|
public interface IDynamicUpdateQueryBuilder : IDynamicQueryBuilder
|
||||||
@@ -5172,6 +5171,7 @@ namespace DynamORM
|
|||||||
#endregion Where
|
#endregion Where
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Interface describing parameter info.</summary>
|
/// <summary>Interface describing parameter info.</summary>
|
||||||
public interface IParameter
|
public interface IParameter
|
||||||
{
|
{
|
||||||
@@ -5195,6 +5195,7 @@ namespace DynamORM
|
|||||||
DynamicSchemaColumn? Schema { get; set; }
|
DynamicSchemaColumn? Schema { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Interface describing table information.</summary>
|
/// <summary>Interface describing table information.</summary>
|
||||||
public interface ITableInfo
|
public interface ITableInfo
|
||||||
{
|
{
|
||||||
@@ -5211,6 +5212,7 @@ namespace DynamORM
|
|||||||
Dictionary<string, DynamicSchemaColumn> Schema { get; }
|
Dictionary<string, DynamicSchemaColumn> Schema { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Extensions
|
namespace Extensions
|
||||||
{
|
{
|
||||||
internal static class DynamicModifyBuilderExtensions
|
internal static class DynamicModifyBuilderExtensions
|
||||||
@@ -5334,6 +5336,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static class DynamicWhereQueryExtensions
|
internal static class DynamicWhereQueryExtensions
|
||||||
{
|
{
|
||||||
#region Where
|
#region Where
|
||||||
@@ -5526,6 +5529,8 @@ namespace DynamORM
|
|||||||
|
|
||||||
#endregion Where
|
#endregion Where
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Implementation
|
namespace Implementation
|
||||||
@@ -5622,6 +5627,7 @@ namespace DynamORM
|
|||||||
#endregion Where
|
#endregion Where
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Implementation of dynamic insert query builder.</summary>
|
/// <summary>Implementation of dynamic insert query builder.</summary>
|
||||||
internal class DynamicInsertQueryBuilder : DynamicModifyBuilder, IDynamicInsertQueryBuilder
|
internal class DynamicInsertQueryBuilder : DynamicModifyBuilder, IDynamicInsertQueryBuilder
|
||||||
{
|
{
|
||||||
@@ -5776,7 +5782,13 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
foreach (var con in dict)
|
foreach (var con in dict)
|
||||||
if (!mapper.Ignored.Contains(con.Key))
|
if (!mapper.Ignored.Contains(con.Key))
|
||||||
Insert(mapper.PropertyMap.TryGetValue(con.Key) ?? con.Key, con.Value);
|
{
|
||||||
|
var colName = mapper.PropertyMap.TryGetValue(con.Key) ?? con.Key;
|
||||||
|
var propMap = mapper.ColumnsMap.TryGetValue(colName.ToLower());
|
||||||
|
|
||||||
|
if (propMap == null || propMap.Column == null || !propMap.Column.IsNoInsert)
|
||||||
|
Insert(colName, con.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
foreach (var con in dict)
|
foreach (var con in dict)
|
||||||
@@ -5788,6 +5800,7 @@ namespace DynamORM
|
|||||||
#endregion Insert
|
#endregion Insert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Base query builder for insert/update/delete statements.</summary>
|
/// <summary>Base query builder for insert/update/delete statements.</summary>
|
||||||
internal abstract class DynamicModifyBuilder : DynamicQueryBuilder
|
internal abstract class DynamicModifyBuilder : DynamicQueryBuilder
|
||||||
{
|
{
|
||||||
@@ -5827,6 +5840,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Implementation of dynamic query builder base interface.</summary>
|
/// <summary>Implementation of dynamic query builder base interface.</summary>
|
||||||
internal abstract class DynamicQueryBuilder : IDynamicQueryBuilder
|
internal abstract class DynamicQueryBuilder : IDynamicQueryBuilder
|
||||||
{
|
{
|
||||||
@@ -6575,6 +6589,7 @@ namespace DynamORM
|
|||||||
#endregion Helpers
|
#endregion Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Implementation of dynamic select query builder.</summary>
|
/// <summary>Implementation of dynamic select query builder.</summary>
|
||||||
internal class DynamicSelectQueryBuilder : DynamicQueryBuilder, IDynamicSelectQueryBuilder, DynamicQueryBuilder.IQueryWithWhere
|
internal class DynamicSelectQueryBuilder : DynamicQueryBuilder, IDynamicSelectQueryBuilder, DynamicQueryBuilder.IQueryWithWhere
|
||||||
{
|
{
|
||||||
@@ -7830,6 +7845,7 @@ namespace DynamORM
|
|||||||
#endregion Helpers
|
#endregion Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Update query builder.</summary>
|
/// <summary>Update query builder.</summary>
|
||||||
internal class DynamicUpdateQueryBuilder : DynamicModifyBuilder, IDynamicUpdateQueryBuilder, DynamicQueryBuilder.IQueryWithWhere
|
internal class DynamicUpdateQueryBuilder : DynamicModifyBuilder, IDynamicUpdateQueryBuilder, DynamicQueryBuilder.IQueryWithWhere
|
||||||
{
|
{
|
||||||
@@ -7927,7 +7943,9 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Values(colName, con.Value);
|
var propMap = mapper.ColumnsMap.TryGetValue(colName.ToLower());
|
||||||
|
if (propMap == null || propMap.Column == null || !propMap.Column.IsNoUpdate)
|
||||||
|
Values(colName, con.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -8110,7 +8128,10 @@ namespace DynamORM
|
|||||||
|
|
||||||
#endregion Where
|
#endregion Where
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Helpers
|
namespace Helpers
|
||||||
@@ -8208,6 +8229,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Framework detection and specific implementations.</summary>
|
/// <summary>Framework detection and specific implementations.</summary>
|
||||||
public static class FrameworkTools
|
public static class FrameworkTools
|
||||||
{
|
{
|
||||||
@@ -8328,6 +8350,7 @@ namespace DynamORM
|
|||||||
#endregion GetGenericTypeArguments
|
#endregion GetGenericTypeArguments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Extends <see cref="IDisposable"/> interface.</summary>
|
/// <summary>Extends <see cref="IDisposable"/> interface.</summary>
|
||||||
public interface IExtendedDisposable : IDisposable
|
public interface IExtendedDisposable : IDisposable
|
||||||
{
|
{
|
||||||
@@ -8340,6 +8363,7 @@ namespace DynamORM
|
|||||||
bool IsDisposed { get; }
|
bool IsDisposed { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Class containing useful string extensions.</summary>
|
/// <summary>Class containing useful string extensions.</summary>
|
||||||
internal static class StringExtensions
|
internal static class StringExtensions
|
||||||
{
|
{
|
||||||
@@ -8637,6 +8661,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Class contains unclassified extensions.</summary>
|
/// <summary>Class contains unclassified extensions.</summary>
|
||||||
internal static class UnclassifiedExtensions
|
internal static class UnclassifiedExtensions
|
||||||
{
|
{
|
||||||
@@ -8680,6 +8705,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Dynamics
|
namespace Dynamics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -9776,6 +9802,7 @@ namespace DynamORM
|
|||||||
#endregion Implementation of IExtendedDisposable
|
#endregion Implementation of IExtendedDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Class that allows to use interfaces as dynamic objects.</summary>
|
/// <summary>Class that allows to use interfaces as dynamic objects.</summary>
|
||||||
/// <typeparam name="T">Type of class to proxy.</typeparam>
|
/// <typeparam name="T">Type of class to proxy.</typeparam>
|
||||||
/// <remarks>This is temporary solution. Which allows to use builders as a dynamic type.</remarks>
|
/// <remarks>This is temporary solution. Which allows to use builders as a dynamic type.</remarks>
|
||||||
@@ -10007,7 +10034,10 @@ namespace DynamORM
|
|||||||
return arguments.Concat(parameters.Skip(arguments.Length).Select(p => p.DefaultValue)).ToArray();
|
return arguments.Concat(parameters.Skip(arguments.Length).Select(p => p.DefaultValue)).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Mapper
|
namespace Mapper
|
||||||
@@ -10042,6 +10072,14 @@ namespace DynamORM
|
|||||||
/// <remarks>Used when overriding schema.</remarks>
|
/// <remarks>Used when overriding schema.</remarks>
|
||||||
public byte? Scale { get; set; }
|
public byte? Scale { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Gets or sets a value indicating whether this kolumn is no allowed to be inserted.</summary>
|
||||||
|
/// <remarks>This is only a suggesstion to automated mapping.</remarks>
|
||||||
|
public bool IsNoInsert { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Gets or sets a value indicating whether this kolumn is no allowed to be updated.</summary>
|
||||||
|
/// <remarks>This is only a suggesstion to automated mapping.</remarks>
|
||||||
|
public bool IsNoUpdate { get; set; }
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
@@ -10056,6 +10094,13 @@ namespace DynamORM
|
|||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
|
/// <param name="isKey">Set column as a key column.</param>
|
||||||
|
public ColumnAttribute(bool isKey)
|
||||||
|
{
|
||||||
|
IsKey = isKey;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
/// <param name="name">Name of column.</param>
|
/// <param name="name">Name of column.</param>
|
||||||
/// <param name="isKey">Set column as a key column.</param>
|
/// <param name="isKey">Set column as a key column.</param>
|
||||||
@@ -10065,6 +10110,15 @@ namespace DynamORM
|
|||||||
IsKey = isKey;
|
IsKey = isKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
|
/// <param name="isKey">Set column as a key column.</param>
|
||||||
|
/// <param name="type">Set column type.</param>
|
||||||
|
public ColumnAttribute(bool isKey, DbType type)
|
||||||
|
: this(isKey)
|
||||||
|
{
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
/// <param name="name">Name of column.</param>
|
/// <param name="name">Name of column.</param>
|
||||||
/// <param name="isKey">Set column as a key column.</param>
|
/// <param name="isKey">Set column as a key column.</param>
|
||||||
@@ -10129,6 +10183,7 @@ namespace DynamORM
|
|||||||
#endregion Constructors
|
#endregion Constructors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Class with mapper cache.</summary>
|
/// <summary>Class with mapper cache.</summary>
|
||||||
public static class DynamicMapperCache
|
public static class DynamicMapperCache
|
||||||
{
|
{
|
||||||
@@ -10170,6 +10225,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Dynamic property invoker.</summary>
|
/// <summary>Dynamic property invoker.</summary>
|
||||||
public class DynamicPropertyInvoker
|
public class DynamicPropertyInvoker
|
||||||
{
|
{
|
||||||
@@ -10264,6 +10320,7 @@ namespace DynamORM
|
|||||||
#endregion Type command cache
|
#endregion Type command cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Represents type columnMap.</summary>
|
/// <summary>Represents type columnMap.</summary>
|
||||||
public class DynamicTypeMap
|
public class DynamicTypeMap
|
||||||
{
|
{
|
||||||
@@ -10379,6 +10436,7 @@ namespace DynamORM
|
|||||||
#endregion Type command cache
|
#endregion Type command cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Allows to add ignore action to property.</summary>
|
/// <summary>Allows to add ignore action to property.</summary>
|
||||||
/// <remarks>Property still get's mapped from output.</remarks>
|
/// <remarks>Property still get's mapped from output.</remarks>
|
||||||
[AttributeUsage(AttributeTargets.Property)]
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
@@ -10386,6 +10444,7 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Allows to add table name to class.</summary>
|
/// <summary>Allows to add table name to class.</summary>
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
public class TableAttribute : Attribute
|
public class TableAttribute : Attribute
|
||||||
@@ -10402,5 +10461,9 @@ namespace DynamORM
|
|||||||
/// set this to true to get schema from type.</remarks>
|
/// set this to true to get schema from type.</remarks>
|
||||||
public bool Override { get; set; }
|
public bool Override { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
DynamORM.sln
12
DynamORM.sln
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamORM.Tests", "DynamORM.
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmalgamationTool", "AmalgamationTool\AmalgamationTool.csproj", "{A64D2052-D0CD-488E-BF05-E5952615D926}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmalgamationTool", "AmalgamationTool\AmalgamationTool.csproj", "{A64D2052-D0CD-488E-BF05-E5952615D926}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{F747AA57-BEA7-4FB8-B371-546296789AEF}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -47,6 +49,16 @@ Global
|
|||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Mixed Platforms.Build.0 = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.ActiveCfg = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.ActiveCfg = Release|x86
|
||||||
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.Build.0 = Release|x86
|
{A64D2052-D0CD-488E-BF05-E5952615D926}.Release|x86.Build.0 = Release|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|Any CPU.ActiveCfg = Release|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{F747AA57-BEA7-4FB8-B371-546296789AEF}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -190,7 +190,13 @@ namespace DynamORM.Builders.Implementation
|
|||||||
{
|
{
|
||||||
foreach (var con in dict)
|
foreach (var con in dict)
|
||||||
if (!mapper.Ignored.Contains(con.Key))
|
if (!mapper.Ignored.Contains(con.Key))
|
||||||
Insert(mapper.PropertyMap.TryGetValue(con.Key) ?? con.Key, con.Value);
|
{
|
||||||
|
var colName = mapper.PropertyMap.TryGetValue(con.Key) ?? con.Key;
|
||||||
|
var propMap = mapper.ColumnsMap.TryGetValue(colName.ToLower());
|
||||||
|
|
||||||
|
if (propMap == null || propMap.Column == null || !propMap.Column.IsNoInsert)
|
||||||
|
Insert(colName, con.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
foreach (var con in dict)
|
foreach (var con in dict)
|
||||||
|
|||||||
@@ -134,7 +134,9 @@ namespace DynamORM.Builders.Implementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Values(colName, con.Value);
|
var propMap = mapper.ColumnsMap.TryGetValue(colName.ToLower());
|
||||||
|
if (propMap == null || propMap.Column == null || !propMap.Column.IsNoUpdate)
|
||||||
|
Values(colName, con.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -349,43 +349,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchInsert<T>(mapper, cmd, parameters);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Insert<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parameters[cp] = temp[p.Name];
|
|
||||||
parameters[cp].InsertCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
ib.Insert(col, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmd);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.InsertCommandText = cmd.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var o in e)
|
foreach (var o in e)
|
||||||
{
|
{
|
||||||
@@ -483,48 +447,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchUpdate<T>(mapper, cmd, parameters);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Update<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parameters[cp] = temp[p.Name];
|
|
||||||
parameters[cp].UpdateCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
{
|
|
||||||
if (currentprop.Column != null && currentprop.Column.IsKey)
|
|
||||||
ib.Where(col, null);
|
|
||||||
else
|
|
||||||
ib.Values(col, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmd);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.UpdateCommandText = cmd.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var o in e)
|
foreach (var o in e)
|
||||||
{
|
{
|
||||||
@@ -593,48 +516,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchUpdate<T>(mapper, cmdUp, parametersUp);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Update<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parametersUp[cp] = temp[p.Name];
|
|
||||||
parametersUp[cp].UpdateCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
{
|
|
||||||
if (currentprop.Column != null && currentprop.Column.IsKey)
|
|
||||||
ib.Where(col, null);
|
|
||||||
else
|
|
||||||
ib.Values(col, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmdUp);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.UpdateCommandText = cmdUp.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Update
|
#endregion Update
|
||||||
|
|
||||||
@@ -659,43 +541,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchInsert<T>(mapper, cmdIn, parametersIn);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Insert<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parametersIn[cp] = temp[p.Name];
|
|
||||||
parametersIn[cp].InsertCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
ib.Insert(col, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmdIn);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.InsertCommandText = cmdIn.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Insert
|
#endregion Insert
|
||||||
|
|
||||||
@@ -796,46 +642,7 @@ namespace DynamORM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
PrepareBatchDelete<T>(mapper, cmd, parameters);
|
||||||
DynamicPropertyInvoker currentprop = null;
|
|
||||||
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
|
||||||
int ord = 0;
|
|
||||||
|
|
||||||
var ib = Delete<T>()
|
|
||||||
.SetVirtualMode(true)
|
|
||||||
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
|
||||||
.CreateParameterAction((p, cp) =>
|
|
||||||
{
|
|
||||||
parameters[cp] = temp[p.Name];
|
|
||||||
parameters[cp].DeleteCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
|
||||||
{
|
|
||||||
Name = cp.ParameterName,
|
|
||||||
Type = cp.DbType,
|
|
||||||
Ordinal = ord++,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var prop in mapper.PropertyMap)
|
|
||||||
if (!mapper.Ignored.Contains(prop.Key))
|
|
||||||
{
|
|
||||||
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
|
||||||
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
|
||||||
|
|
||||||
if (currentprop.Ignore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentprop.Get != null)
|
|
||||||
{
|
|
||||||
if (currentprop.Column != null && currentprop.Column.IsKey)
|
|
||||||
ib.Where(col, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ib.FillCommand(cmd);
|
|
||||||
|
|
||||||
// Cache command
|
|
||||||
mapper.DeleteCommandText = cmd.CommandText;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var o in e)
|
foreach (var o in e)
|
||||||
{
|
{
|
||||||
@@ -865,6 +672,190 @@ namespace DynamORM
|
|||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PrepareBatchInsert<T>(DynamicTypeMap mapper, IDbCommand cmd, Dictionary<IDbDataParameter, DynamicPropertyInvoker> parameters)
|
||||||
|
{
|
||||||
|
DynamicPropertyInvoker currentprop = null;
|
||||||
|
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
||||||
|
var schema = this.GetSchema<T>();
|
||||||
|
int ord = 0;
|
||||||
|
|
||||||
|
var ib = Insert<T>()
|
||||||
|
.SetVirtualMode(true)
|
||||||
|
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
||||||
|
.CreateParameterAction((p, cp) =>
|
||||||
|
{
|
||||||
|
parameters[cp] = temp[p.Name];
|
||||||
|
parameters[cp].InsertCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
||||||
|
{
|
||||||
|
Name = cp.ParameterName,
|
||||||
|
Type = cp.DbType,
|
||||||
|
Ordinal = ord++,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var prop in mapper.PropertyMap)
|
||||||
|
if (!mapper.Ignored.Contains(prop.Key))
|
||||||
|
{
|
||||||
|
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
||||||
|
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
||||||
|
|
||||||
|
if (currentprop.Ignore || (currentprop.Column != null && currentprop.Column.IsNoInsert))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (currentprop.Get != null)
|
||||||
|
ib.Insert(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = schema == null ? null : schema.TryGetNullable(col.ToLower()),
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ib.FillCommand(cmd);
|
||||||
|
|
||||||
|
// Cache command
|
||||||
|
mapper.InsertCommandText = cmd.CommandText;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrepareBatchUpdate<T>(DynamicTypeMap mapper, IDbCommand cmd, Dictionary<IDbDataParameter, DynamicPropertyInvoker> parameters)
|
||||||
|
{
|
||||||
|
DynamicPropertyInvoker currentprop = null;
|
||||||
|
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
||||||
|
var schema = this.GetSchema<T>();
|
||||||
|
int ord = 0;
|
||||||
|
|
||||||
|
var ib = Update<T>()
|
||||||
|
.SetVirtualMode(true)
|
||||||
|
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
||||||
|
.CreateParameterAction((p, cp) =>
|
||||||
|
{
|
||||||
|
parameters[cp] = temp[p.Name];
|
||||||
|
parameters[cp].UpdateCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
||||||
|
{
|
||||||
|
Name = cp.ParameterName,
|
||||||
|
Type = cp.DbType,
|
||||||
|
Ordinal = ord++,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var prop in mapper.PropertyMap)
|
||||||
|
if (!mapper.Ignored.Contains(prop.Key))
|
||||||
|
{
|
||||||
|
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
||||||
|
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
||||||
|
|
||||||
|
if (currentprop.Ignore)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (currentprop.Get != null)
|
||||||
|
{
|
||||||
|
var colS = schema == null ? null : schema.TryGetNullable(col.ToLower());
|
||||||
|
|
||||||
|
if (colS.HasValue)
|
||||||
|
{
|
||||||
|
if (colS.Value.IsKey)
|
||||||
|
ib.Where(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
else if (currentprop.Column == null || !currentprop.Column.IsNoUpdate)
|
||||||
|
ib.Values(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (currentprop.Column != null && currentprop.Column.IsKey)
|
||||||
|
ib.Where(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ib.FillCommand(cmd);
|
||||||
|
|
||||||
|
// Cache command
|
||||||
|
mapper.UpdateCommandText = cmd.CommandText;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrepareBatchDelete<T>(DynamicTypeMap mapper, IDbCommand cmd, Dictionary<IDbDataParameter, DynamicPropertyInvoker> parameters)
|
||||||
|
{
|
||||||
|
DynamicPropertyInvoker currentprop = null;
|
||||||
|
var temp = new Dictionary<string, DynamicPropertyInvoker>();
|
||||||
|
var schema = this.GetSchema<T>();
|
||||||
|
int ord = 0;
|
||||||
|
|
||||||
|
var ib = Delete<T>()
|
||||||
|
.SetVirtualMode(true)
|
||||||
|
.CreateTemporaryParameterAction(p => temp[p.Name] = currentprop)
|
||||||
|
.CreateParameterAction((p, cp) =>
|
||||||
|
{
|
||||||
|
parameters[cp] = temp[p.Name];
|
||||||
|
parameters[cp].DeleteCommandParameter = new DynamicPropertyInvoker.ParameterSpec
|
||||||
|
{
|
||||||
|
Name = cp.ParameterName,
|
||||||
|
Type = cp.DbType,
|
||||||
|
Ordinal = ord++,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var prop in mapper.PropertyMap)
|
||||||
|
if (!mapper.Ignored.Contains(prop.Key))
|
||||||
|
{
|
||||||
|
var col = mapper.PropertyMap.TryGetValue(prop.Key) ?? prop.Key;
|
||||||
|
currentprop = mapper.ColumnsMap.TryGetValue(col.ToLower());
|
||||||
|
|
||||||
|
if (currentprop.Ignore)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (currentprop.Get != null)
|
||||||
|
{
|
||||||
|
var colS = schema == null ? null : schema.TryGetNullable(col.ToLower());
|
||||||
|
|
||||||
|
if (colS != null)
|
||||||
|
{
|
||||||
|
if (colS.Value.IsKey)
|
||||||
|
ib.Where(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (currentprop.Column != null && currentprop.Column.IsKey)
|
||||||
|
ib.Where(new DynamicColumn()
|
||||||
|
{
|
||||||
|
ColumnName = col,
|
||||||
|
Schema = colS,
|
||||||
|
Operator = DynamicColumn.CompareOperator.Eq,
|
||||||
|
Value = null,
|
||||||
|
VirtualColumn = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ib.FillCommand(cmd);
|
||||||
|
|
||||||
|
// Cache command
|
||||||
|
mapper.DeleteCommandText = cmd.CommandText;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion From/Insert/Update/Delete
|
#endregion From/Insert/Update/Delete
|
||||||
|
|
||||||
#region Schema
|
#region Schema
|
||||||
@@ -895,7 +886,7 @@ namespace DynamORM
|
|||||||
Dictionary<string, DynamicSchemaColumn> schema = null;
|
Dictionary<string, DynamicSchemaColumn> schema = null;
|
||||||
|
|
||||||
lock (SyncLock)
|
lock (SyncLock)
|
||||||
schema = Schema.TryGetValue(typeof(T).GetType().FullName) ??
|
schema = Schema.TryGetValue(typeof(T).FullName) ??
|
||||||
BuildAndCacheSchema(null, DynamicMapperCache.GetMapper<T>());
|
BuildAndCacheSchema(null, DynamicMapperCache.GetMapper<T>());
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
@@ -977,7 +968,8 @@ namespace DynamORM
|
|||||||
|
|
||||||
#region Type schema
|
#region Type schema
|
||||||
|
|
||||||
if (mapperSchema && !Schema.ContainsKey(mapper.Type.FullName))
|
if ((mapperSchema && !Schema.ContainsKey(mapper.Type.FullName)) ||
|
||||||
|
(schema == null && !mapper.Type.IsAnonymous()))
|
||||||
{
|
{
|
||||||
// TODO: Ged rid of this monster below...
|
// TODO: Ged rid of this monster below...
|
||||||
if (databaseSchemaSupport)
|
if (databaseSchemaSupport)
|
||||||
@@ -999,7 +991,7 @@ namespace DynamORM
|
|||||||
col.HasValue ? col.Value.IsKey : false).Value,
|
col.HasValue ? col.Value.IsKey : false).Value,
|
||||||
Type = DynamicExtensions.CoalesceNullable<DbType>(
|
Type = DynamicExtensions.CoalesceNullable<DbType>(
|
||||||
v.Value.Column != null ? v.Value.Column.Type : null,
|
v.Value.Column != null ? v.Value.Column.Type : null,
|
||||||
col.HasValue ? col.Value.Type : DbType.String).Value,
|
col.HasValue ? col.Value.Type : DynamicExtensions.TypeMap.TryGetNullable(v.Value.Type) ?? DbType.String).Value,
|
||||||
IsUnique = DynamicExtensions.CoalesceNullable<bool>(
|
IsUnique = DynamicExtensions.CoalesceNullable<bool>(
|
||||||
v.Value.Column != null ? v.Value.Column.IsUnique : null,
|
v.Value.Column != null ? v.Value.Column.IsUnique : null,
|
||||||
col.HasValue ? col.Value.IsUnique : false).Value,
|
col.HasValue ? col.Value.IsUnique : false).Value,
|
||||||
@@ -1026,7 +1018,7 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
Name = DynamicExtensions.Coalesce<string>(v.Value.Column == null || string.IsNullOrEmpty(v.Value.Column.Name) ? null : v.Value.Column.Name, v.Value.Name),
|
Name = DynamicExtensions.Coalesce<string>(v.Value.Column == null || string.IsNullOrEmpty(v.Value.Column.Name) ? null : v.Value.Column.Name, v.Value.Name),
|
||||||
IsKey = DynamicExtensions.CoalesceNullable<bool>(v.Value.Column != null ? v.Value.Column.IsKey : false, false).Value,
|
IsKey = DynamicExtensions.CoalesceNullable<bool>(v.Value.Column != null ? v.Value.Column.IsKey : false, false).Value,
|
||||||
Type = DynamicExtensions.CoalesceNullable<DbType>(v.Value.Column != null ? v.Value.Column.Type : null, DbType.String).Value,
|
Type = DynamicExtensions.CoalesceNullable<DbType>(v.Value.Column != null ? v.Value.Column.Type : null, DynamicExtensions.TypeMap.TryGetNullable(v.Value.Type)).Value,
|
||||||
IsUnique = DynamicExtensions.CoalesceNullable<bool>(v.Value.Column != null ? v.Value.Column.IsUnique : null, false).Value,
|
IsUnique = DynamicExtensions.CoalesceNullable<bool>(v.Value.Column != null ? v.Value.Column.IsUnique : null, false).Value,
|
||||||
Size = DynamicExtensions.CoalesceNullable<int>(v.Value.Column != null ? v.Value.Column.Size : null, 0).Value,
|
Size = DynamicExtensions.CoalesceNullable<int>(v.Value.Column != null ? v.Value.Column.Size : null, 0).Value,
|
||||||
Precision = DynamicExtensions.CoalesceNullable<byte>(v.Value.Column != null ? v.Value.Column.Precision : null, 0).Value,
|
Precision = DynamicExtensions.CoalesceNullable<byte>(v.Value.Column != null ? v.Value.Column.Precision : null, 0).Value,
|
||||||
|
|||||||
@@ -680,7 +680,8 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var name = info.ArgumentNames[i].ToLower();
|
var fullName = info.ArgumentNames[i];
|
||||||
|
var name = fullName.ToLower();
|
||||||
|
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
@@ -701,7 +702,7 @@ namespace DynamORM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
builder.Insert(name, args[i]);
|
builder.Insert(fullName, args[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -726,7 +727,8 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var name = info.ArgumentNames[i].ToLower();
|
var fullName = info.ArgumentNames[i];
|
||||||
|
var name = fullName.ToLower();
|
||||||
|
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
@@ -755,7 +757,7 @@ namespace DynamORM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
builder.Update(name, args[i]);
|
builder.Update(fullName, args[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -780,7 +782,8 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var name = info.ArgumentNames[i].ToLower();
|
var fullName = info.ArgumentNames[i];
|
||||||
|
var name = fullName.ToLower();
|
||||||
|
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
@@ -805,7 +808,7 @@ namespace DynamORM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
builder.Where(name, args[i]);
|
builder.Where(fullName, args[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -831,7 +834,8 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var name = info.ArgumentNames[i].ToLower();
|
var fullName = info.ArgumentNames[i];
|
||||||
|
var name = fullName.ToLower();
|
||||||
|
|
||||||
// TODO: Make this nicer
|
// TODO: Make this nicer
|
||||||
switch (name)
|
switch (name)
|
||||||
@@ -906,7 +910,7 @@ namespace DynamORM
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
builder.Where(name, args[i]);
|
builder.Where(fullName, args[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,10 +61,20 @@ namespace DynamORM.Mapper
|
|||||||
/// <remarks>Used when overriding schema.</remarks>
|
/// <remarks>Used when overriding schema.</remarks>
|
||||||
public byte? Scale { get; set; }
|
public byte? Scale { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Gets or sets a value indicating whether this kolumn is no allowed to be inserted.</summary>
|
||||||
|
/// <remarks>This is only a suggesstion to automated mapping.</remarks>
|
||||||
|
public bool IsNoInsert { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Gets or sets a value indicating whether this kolumn is no allowed to be updated.</summary>
|
||||||
|
/// <remarks>This is only a suggesstion to automated mapping.</remarks>
|
||||||
|
public bool IsNoUpdate { get; set; }
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
public ColumnAttribute() { }
|
public ColumnAttribute()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
/// <param name="name">Name of column.</param>
|
/// <param name="name">Name of column.</param>
|
||||||
@@ -73,6 +83,13 @@ namespace DynamORM.Mapper
|
|||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
|
/// <param name="isKey">Set column as a key column.</param>
|
||||||
|
public ColumnAttribute(bool isKey)
|
||||||
|
{
|
||||||
|
IsKey = isKey;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
/// <param name="name">Name of column.</param>
|
/// <param name="name">Name of column.</param>
|
||||||
/// <param name="isKey">Set column as a key column.</param>
|
/// <param name="isKey">Set column as a key column.</param>
|
||||||
@@ -82,6 +99,15 @@ namespace DynamORM.Mapper
|
|||||||
IsKey = isKey;
|
IsKey = isKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
|
/// <param name="isKey">Set column as a key column.</param>
|
||||||
|
/// <param name="type">Set column type.</param>
|
||||||
|
public ColumnAttribute(bool isKey, DbType type)
|
||||||
|
: this(isKey)
|
||||||
|
{
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="ColumnAttribute" /> class.</summary>
|
||||||
/// <param name="name">Name of column.</param>
|
/// <param name="name">Name of column.</param>
|
||||||
/// <param name="isKey">Set column as a key column.</param>
|
/// <param name="isKey">Set column as a key column.</param>
|
||||||
|
|||||||
56
Tester/Program.cs
Normal file
56
Tester/Program.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using DynamORM;
|
||||||
|
using DynamORM.Mapper;
|
||||||
|
|
||||||
|
namespace Tester
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
[Table(Name = "dist_Distances")]
|
||||||
|
public class Distance
|
||||||
|
{
|
||||||
|
[Column(IsKey = true)]
|
||||||
|
public Guid StartAddress_Id { get; set; }
|
||||||
|
|
||||||
|
[Column(IsKey = true)]
|
||||||
|
public Guid EndAddress_Id { get; set; }
|
||||||
|
|
||||||
|
[Column(IsKey = true)]
|
||||||
|
public int VehicleType { get; set; }
|
||||||
|
|
||||||
|
[Column]
|
||||||
|
public int PostcodeDistanceInSecs { get; set; }
|
||||||
|
|
||||||
|
[Column]
|
||||||
|
public decimal PostcodeDistanceInKms { get; set; }
|
||||||
|
|
||||||
|
[Column]
|
||||||
|
public int IsDepotDistance { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
|
string conns = string.Format("Server={0};Port={1};Userid={2};Password={3};Database={4};Protocol=3;SSL=false;Pooling=true;MinPoolSize=1;MaxPoolSize=20;Encoding=UNICODE;Timeout=15;",
|
||||||
|
"192.168.1.6", 5432, "ted", "ted123", "TED_Altom");
|
||||||
|
|
||||||
|
using (var db = new DynamicDatabase(Npgsql.NpgsqlFactory.Instance, conns, DynamORM.DynamicDatabaseOptions.SupportSchema | DynamORM.DynamicDatabaseOptions.SupportLimitOffset))
|
||||||
|
{
|
||||||
|
var s = db.GetSchema<Distance>();
|
||||||
|
Console.Out.WriteLine(s.Count);
|
||||||
|
|
||||||
|
DynamicTypeMap mapper = DynamORM.Mapper.DynamicMapperCache.GetMapper<Distance>();
|
||||||
|
using (var con = db.Open())
|
||||||
|
using (var cmd = con.CreateCommand())
|
||||||
|
{
|
||||||
|
Dictionary<IDbDataParameter, DynamicPropertyInvoker> parameters = new Dictionary<IDbDataParameter, DynamicPropertyInvoker>();
|
||||||
|
|
||||||
|
db.Insert<Distance>(new Distance[] { });
|
||||||
|
|
||||||
|
//db.PrepareBatchInsert<Distance>(mapper, cmd, parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Tester/Properties/AssemblyInfo.cs
Normal file
36
Tester/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Tester")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("Tester")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("dbff9475-06f5-400e-bc17-57c14d9d9cb9")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
66
Tester/Tester.csproj
Normal file
66
Tester/Tester.csproj
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{F747AA57-BEA7-4FB8-B371-546296789AEF}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Tester</RootNamespace>
|
||||||
|
<AssemblyName>Tester</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Npgsql">
|
||||||
|
<HintPath>..\..\..\..\..\Development\Source\TED\Demo\Libraries\Npgsql.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DynamORM\DynamORM.csproj">
|
||||||
|
<Project>{63963ED7-9C78-4672-A4D4-339B6E825503}</Project>
|
||||||
|
<Name>DynamORM</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user