Пример #1
0
 public static void ExcExpression()
 {
     ModelTest model1=new ModelTest{ID=1,Name="bbb"};
     ModelTest model2 = new ModelTest { ID = 2 };
     Expression<Func<ModelTest, Object>> predicate = m => m.Name;
     Object s1 = predicate.Compile()(model1) ?? "N/A";
     Object s2 = predicate.Compile()(model2) ?? "N/A";
 }
Пример #2
0
 public static void ExcExpression()
 {
     ModelTest model1 = new ModelTest {
         ID = 1, Name = "bbb"
     };
     ModelTest model2 = new ModelTest {
         ID = 2
     };
     Expression <Func <ModelTest, Object> > predicate = m => m.Name;
     Object s1 = predicate.Compile()(model1) ?? "N/A";
     Object s2 = predicate.Compile()(model2) ?? "N/A";
 }