Before I had
public static System.Linq.Expressions.Expression<Func<MetaMovie, bool>> IsEqual(MetaMovie other)
{
if (other.Id > 0) return m => other.Id == m.Id;
return m => other.MetaSource == m.MetaSource && other.ExternalId == m.ExternalId;
}
DebugView of a variable assigned the call of the above method:
.Lambda #Lambda1<System.Func`2[com.cyberinternauts.all.MediaRecognizer.Models.Metas.MetaMovie,System.Boolean]>(com.cyberinternauts.all.MediaRecognizer.Models.Metas.MetaMovie $m)
{
(.Constant<com.cyberinternauts.all.MediaRecognizer.Models.Metas.MetaMovie+<>c__DisplayClass81_0>(com.cyberinternauts.all.MediaRecognizer.Models.Metas.MetaMovie+<>c__DisplayClass81_0).other).MetaSource ==
$m.MetaSource && (.Constant<com.cyberinternauts.all.MediaRecognizer.Models.Metas.MetaMovie+<>c__DisplayClass81_0>(com.cyberinternauts.all.MediaRecognizer.Models.Metas.MetaMovie+<>c__DisplayClass81_0).other).ExternalId ==
$m.ExternalId
}
... that I would like to obtain the same using...
Now I want
I would like to create a method Func<MetaMovie, bool> NAME(MetaMovie other)
that would be called by IsEqual
. I did the new method called GetComparison
, but I am not able to integrate it my IsEqual
method.
I tried
public static Func<MetaMovie, bool> GetComparison(MetaMovie other)
{
if (other.Id > 0) return m => other.Id == m.Id;
return m => other.MetaSource == m.MetaSource && other.ExternalId == m.ExternalId;
}
public static Expression<Func<MetaMovie, bool>> IsEqual(MetaMovie other)
{
var param1 = Expression.Parameter(other.GetType(), "param1");
return Expression.Lambda<Func<MetaMovie, bool>>(Expression.Call(GetComparison(other).Method), param1);
}
Error
I am getting the follow error on the return line of IsEqual
Static method requires null instance, non-static method requires non-null instance