Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 241f3d0

Browse files
authored
Merge pull request #525 from KevinHoward/master
A few minor changes to consolidate SqlExpression.cs
2 parents a4be4b7 + 39df651 commit 241f3d0

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

src/ServiceStack.OrmLite.Sqlite/SqliteExpression.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public override SqlExpression<T> OrderByRandom()
8080

8181
protected override PartialSqlString ToConcatPartialString(List<Object> args)
8282
{
83-
;return new PartialSqlString(String.Join(" || ", args));
83+
return new PartialSqlString(String.Join(" || ", args));
8484
}
8585
}
86-
}
86+
}

src/ServiceStack.OrmLite/Expressions/SqlExpression.cs

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,8 +1720,12 @@ private object GetNotValue(object o)
17201720

17211721
private bool IsColumnAccess(MethodCallExpression m)
17221722
{
1723-
if (m.Object != null && m.Object as MethodCallExpression != null)
1724-
return IsColumnAccess(m.Object as MethodCallExpression);
1723+
if (m.Object == null)
1724+
return false;
1725+
1726+
var methCallExp = m.Object as MethodCallExpression;
1727+
if (methCallExp != null)
1728+
return IsColumnAccess(methCallExp);
17251729

17261730
var exp = m.Object as MemberExpression;
17271731
return IsParameterAccess(exp)
@@ -1930,14 +1934,11 @@ public IList<string> GetAllFields()
19301934
return modelDef.FieldDefinitions.ConvertAll(r => r.Name);
19311935
}
19321936

1933-
private bool IsStaticArrayMethod(MethodCallExpression m)
1937+
private static bool IsStaticArrayMethod(MethodCallExpression m)
19341938
{
1935-
if (m.Object == null && m.Method.Name == "Contains")
1936-
{
1937-
return m.Arguments.Count == 2;
1938-
}
1939-
1940-
return false;
1939+
return (m.Object == null
1940+
&& m.Method.Name == "Contains"
1941+
&& m.Arguments.Count == 2);
19411942
}
19421943

19431944
protected virtual object VisitStaticArrayMethodCall(MethodCallExpression m)
@@ -1959,17 +1960,13 @@ protected virtual object VisitStaticArrayMethodCall(MethodCallExpression m)
19591960
}
19601961
}
19611962

1962-
private bool IsEnumerableMethod(MethodCallExpression m)
1963+
private static bool IsEnumerableMethod(MethodCallExpression m)
19631964
{
1964-
if (m.Object != null
1965+
return (m.Object != null
19651966
&& m.Object.Type.IsOrHasGenericInterfaceTypeOf(typeof(IEnumerable<>))
19661967
&& m.Object.Type != typeof(string)
1967-
&& m.Method.Name == "Contains")
1968-
{
1969-
return m.Arguments.Count == 1;
1970-
}
1971-
1972-
return false;
1968+
&& m.Method.Name == "Contains"
1969+
&& m.Arguments.Count == 1);
19731970
}
19741971

19751972
protected virtual object VisitEnumerableMethodCall(MethodCallExpression m)
@@ -2000,14 +1997,10 @@ private object ToInPartialString(Expression memberExpr, object quotedColName)
20001997
return new PartialSqlString(statement);
20011998
}
20021999

2003-
private bool IsStaticStringMethod(MethodCallExpression m)
2000+
private static bool IsStaticStringMethod(MethodCallExpression m)
20042001
{
2005-
if (m.Object == null && m.Method.Name == "Concat")
2006-
{
2007-
return true;
2008-
}
2009-
2010-
return false;
2002+
return (m.Object == null
2003+
&& m.Method.Name == "Concat");
20112004
}
20122005

20132006
protected virtual object VisitStaticStringMethodCall(MethodCallExpression m)
@@ -2051,7 +2044,6 @@ protected virtual object VisitSqlMethodCall(MethodCallExpression m)
20512044
case "In":
20522045
statement = ConvertInExpressionToSql(m, quotedColName);
20532046
break;
2054-
20552047
case "Desc":
20562048
statement = string.Format("{0} DESC", quotedColName);
20572049
break;

0 commit comments

Comments
 (0)