Skip to content

Instantly share code, notes, and snippets.

//x => x.fieldName.Contains(fieldValue)
public static IQueryable<T> FilterByValue<T>(this IQueryable<T> q, string fieldName, string fieldValue)
{
try
{
var param = Expression.Parameter(typeof(T), "p");
var prop = Expression.Property(param, fieldName);
if (((PropertyInfo)prop.Member).PropertyType != typeof(string))
return q;
public static class GuidIntConverter
{
public static Guid ToGuid(int integer)
{
return new GuidConverter(integer).Guid;
}
public static int ToInt(Guid guid)
{
return new GuidConverter(guid).Integer;