Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Test t = new Test(); Console.WriteLine(t.FieldName("Title").FieldName&lt;DatabaseFieldAttribute&gt;()); Console.WriteLine(t.FieldName("Title").FieldIsPrimaryKey&lt;DatabaseFieldAttribute&gt;()); } } public class Test { [DatabaseField("titlezzz", true)] public string Title { get; set; } } public class BaseDatabaseFieldAttribute : Attribute { private readonly string _name; public string Name { get { return _name; } } public BaseDatabaseFieldAttribute(string name) { _name = name; } } public class DatabaseFieldAttribute : BaseDatabaseFieldAttribute { private readonly bool _isPrimaryKey; public bool IsPrimaryKey { get { return _isPrimaryKey; } } public DatabaseFieldAttribute(string name, bool isPrimaryKey): base(name) { _isPrimaryKey = isPrimaryKey; } } public static class Helper { public static PropertyInfo FieldName(this object obj, string propertyName) { return obj.GetType().GetProperty(propertyName); } public static string FieldName&lt;T&gt;(this PropertyInfo property) where T: BaseDatabaseFieldAttribute { object[] os = property.GetCustomAttributes(typeof(T), false); if (os != null &amp;&amp; os.Length &gt;= 1) return (os[0] as T).Name; else return "N/A"; } public static bool? FieldIsPrimaryKey&lt;T&gt;(this PropertyInfo property) where T : DatabaseFieldAttribute { object[] os = property.GetCustomAttributes(typeof(T), false); if (os != null &amp;&amp; os.Length &gt;= 1) return (os[0] as T).IsPrimaryKey; else return null; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload