-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to v3.0.5 direct select Ids type because Expression Constant c…
…annot set List<object> as specific type
- Loading branch information
Showing
8 changed files
with
48 additions
and
32 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
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
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,28 @@ | ||
using System.Linq.Expressions; | ||
using OfX.Exceptions; | ||
|
||
namespace OfX.Helpers; | ||
|
||
public static class GeneralHelpers | ||
{ | ||
public static string GetAssemblyName(this Type type) => $"{type.FullName},{type.Assembly.GetName().Name}"; | ||
|
||
public static ConstantExpression ConstantExpression(List<string> selectorIds, Type idType) | ||
{ | ||
if (idType == typeof(string)) return Expression.Constant(selectorIds); | ||
if (idType == typeof(Guid)) | ||
return Expression.Constant(selectorIds | ||
.Where(a => Guid.TryParse(a, out _)).Select(Guid.Parse).ToList()); | ||
if (idType == typeof(int)) | ||
return Expression.Constant(selectorIds | ||
.Where(a => int.TryParse(a, out _)).Select(int.Parse).ToList()); | ||
if (idType == typeof(long)) | ||
return Expression.Constant(selectorIds | ||
.Where(a => long.TryParse(a, out _)).Select(long.Parse).ToList()); | ||
if (idType == typeof(short)) | ||
return Expression.Constant(selectorIds | ||
.Where(a => short.TryParse(a, out _)).Select(short.Parse).ToList()); | ||
|
||
throw new OfXException.CurrentIdTypeWasNotSupported(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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