Commit edde1eb6 authored by von's avatar von

Support for "ignoring property"

parent 36f51540
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Database.cs" /> <Compile Include="Database.cs" />
<Compile Include="IgnorePropertyAttribute.cs" />
<Compile Include="Snapshotter.cs" /> <Compile Include="Snapshotter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlCompactDatabase.cs" /> <Compile Include="SqlCompactDatabase.cs" />
......
...@@ -129,7 +129,12 @@ internal static List<string> GetParamNames(object o) ...@@ -129,7 +129,12 @@ internal static List<string> GetParamNames(object o)
paramNames = new List<string>(); paramNames = new List<string>();
foreach (var prop in o.GetType().GetProperties(BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public)) foreach (var prop in o.GetType().GetProperties(BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public))
{ {
paramNames.Add(prop.Name); var attribs = prop.GetCustomAttributes(typeof(IgnorePropertyAttribute), true);
var attr = attribs.FirstOrDefault() as IgnorePropertyAttribute;
if (attr==null || (attr != null && !attr.Value))
{
paramNames.Add(prop.Name);
}
} }
paramNameCache[o.GetType()] = paramNames; paramNameCache[o.GetType()] = paramNames;
} }
......
using System;
namespace Dapper
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class IgnorePropertyAttribute : Attribute
{
public IgnorePropertyAttribute(bool ignore)
{
Value = ignore;
}
public bool Value { get; set; }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment