-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from abe545/honor-optional-for-hierarchical-re…
…sults 2.3.0-pre01
- Loading branch information
Showing
12 changed files
with
632 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="DotNet.Contracts" version="1.10.20606.1" targetFramework="net40-client" /> | ||
<package id="EntityFramework" version="6.1.3" targetFramework="net40-Client" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace CodeOnlyStoredProcedure | ||
{ | ||
internal static class PropertyInfoExtensions | ||
{ | ||
public static bool IsOptional(this PropertyInfo pi) | ||
{ | ||
return pi.GetCustomAttributes(false).OfType<OptionalResultAttribute>().Any(); | ||
} | ||
|
||
public static string GetSqlColumnName(this PropertyInfo pi) | ||
{ | ||
var col = pi.GetCustomAttributes(typeof(ColumnAttribute), false) | ||
.OfType<ColumnAttribute>() | ||
.FirstOrDefault(); | ||
|
||
if (col != null && !string.IsNullOrWhiteSpace(col.Name)) | ||
return col.Name; | ||
|
||
var attr = pi.GetCustomAttributes(typeof(StoredProcedureParameterAttribute), false) | ||
.OfType<StoredProcedureParameterAttribute>() | ||
.FirstOrDefault(); | ||
|
||
if (attr != null && !string.IsNullOrWhiteSpace(attr.Name)) | ||
return attr.Name; | ||
|
||
return pi.Name; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.