Can I use ternary operator with a lambda expression?

ساخت وبلاگ

Vote count: 0

I am trying to understand if I can use teary operators within a lambda expression.

For example:

public class Foo
{ public int ID {get; set;} public string Name {get; set;} public Address MyAdd {get; set;}
}

I then want to do something like this:

 var config = new MapperConfiguration(c => { c.CreateMap<foo, MyFoo>() .ForMember(x => x.ID, m => m.MapFrom(a => a.ID)) .ForMember(x => x.Name, m => m.MapFrom(a => a.Name)) .ForMember(x => x.Add1, m => m.MapFrom(a => (a.MyAdd != null) ? a.MyAdd.Line1 : string.Empty)); });

However I get the error:

Cannot convert lambda expression to type 'string' because it is not a delegate type
asked 29 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 294 تاريخ : سه شنبه 29 تير 1395 ساعت: 1:56