Conversion of Linq expressions

Posted by Arnis L. on Stack Overflow See other posts from Stack Overflow or by Arnis L.
Published on 2011-01-10T11:35:24Z Indexed on 2011/01/10 11:53 UTC
Read the original article Hit count: 242

Filed under:
|
|

I'm not sure how exactly argument what I'm trying to achieve, therefore - wrote some code:

public class Foo{
 public Bar Bar{get;set;}
}

public class Bar{
 public string Fizz{get;set;}
}

public class Facts{
 [Fact]
 public void fact(){
   Assert.Equal(expectedExp(),barToFoo(barExp()));
 }
 private Expression<Func<Foo,bool>> expectedExp(){
   return f=>f.Bar.Fizz=="fizz";
 }
 private Expression<Func<Bar,bool>> barExp(){
   return b=>b.Fizz=="fizz";
 }
 private Expression<Func<Foo,bool>> barToFoo
  (Expression<Func<Bar,bool>> barExp){
   return Voodoo(barExp); //<-------------------------------------------???
 }          
}

Is this even possible?

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ