コード例 #1
0
ファイル: TestLinq.cs プロジェクト: jgwynn2901/composite
        public void TestFieldNameAttribute()
        {
            var results = FieldDefintionAttribute.ClassFieldName(typeof(DbClassLibrary.ActiveRecords.Employee), "NameLast");

            Assert.IsNotEmpty(results);
            Assert.IsNull(FieldDefintionAttribute.ClassFieldName(typeof(DbClassLibrary.ActiveRecords.Employee), "Ssn"));
            Console.WriteLine(results);
        }
コード例 #2
0
 protected override Expression VisitMemberAccess(MemberExpression m)
 {
     if (m.Expression != null && m.Expression.NodeType == ExpressionType.Parameter)
     {
         _sb.Append(FieldDefintionAttribute.ClassFieldName(m.Member.DeclaringType, m.Member.Name) ?? m.Member.Name);
         return(m);
     }
     throw new NotSupportedException(string.Format("The member '{0}' is not supported", m.Member.Name));
 }
コード例 #3
0
ファイル: TestLinq.cs プロジェクト: jgwynn2901/composite
        public void TestFieldInfo()
        {
            var hostType = typeof(DbClassLibrary.ActiveRecords.Employee);

            var results = from t in (from p in hostType.GetProperties() select p)
                          from a in t.GetCustomAttributes(true)
                          where a is FieldDefintionAttribute
                          select FieldDefintionAttribute.ClassFieldName(hostType, t.Name) ?? t.Name;

            foreach (var field in results)
            {
                Console.WriteLine(field);
            }

            Assert.IsTrue(typeof(ActiveRecord).IsAssignableFrom(hostType));
        }
コード例 #4
0
ファイル: QueryBinder.cs プロジェクト: jgwynn2901/composite
 private static string GetColumnName(MemberInfo member)
 {
     return(FieldDefintionAttribute.ClassFieldName(member.DeclaringType, member.Name) ?? member.Name);
 }