Commit 4c2362ff authored by Marc Gravell's avatar Marc Gravell

Merge pull request #79 from vonbv/master

Support for "ignoring Navigation Property"
parents 2a3bf22f edde1eb6
......@@ -41,6 +41,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Database.cs" />
<Compile Include="IgnorePropertyAttribute.cs" />
<Compile Include="Snapshotter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlCompactDatabase.cs" />
......
......@@ -128,9 +128,14 @@ internal static List<string> GetParamNames(object o)
{
paramNames = new List<string>();
foreach (var prop in o.GetType().GetProperties(BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public))
{
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;
}
return 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