mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 05:23:31 -07:00
added marr.datamapper source code for easy debugging.
This commit is contained in:
parent
58a05fcef8
commit
3cdff3bb71
96 changed files with 9198 additions and 363 deletions
50
Marr.Data/QGen/SortColumn.cs
Normal file
50
Marr.Data/QGen/SortColumn.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Marr.Data.QGen
|
||||
{
|
||||
public class SortColumn<T>
|
||||
{
|
||||
public SortColumn(Expression<Func<T, object>> sortExpression, SortDirection direction)
|
||||
{
|
||||
MemberExpression me = GetMemberExpression(sortExpression.Body);
|
||||
DeclaringType = me.Expression.Type;
|
||||
PropertyName = me.Member.Name;
|
||||
Direction = direction;
|
||||
}
|
||||
|
||||
public SortColumn(Type declaringType, string propertyName, SortDirection direction)
|
||||
{
|
||||
DeclaringType = declaringType;
|
||||
PropertyName = propertyName;
|
||||
Direction = direction;
|
||||
}
|
||||
|
||||
public SortDirection Direction { get; private set; }
|
||||
public Type DeclaringType { get; private set; }
|
||||
public string PropertyName { get; private set; }
|
||||
|
||||
private MemberExpression GetMemberExpression(Expression exp)
|
||||
{
|
||||
MemberExpression me = exp as MemberExpression;
|
||||
|
||||
if (me == null)
|
||||
{
|
||||
var ue = exp as UnaryExpression;
|
||||
me = ue.Operand as MemberExpression;
|
||||
}
|
||||
|
||||
return me;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SortDirection
|
||||
{
|
||||
Asc,
|
||||
Desc
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue