1
我有2班,想從一個配置映射到另一個如何指定映射規則一堆性質
public class Customer
{
public long CustomerId{get;set;}
public string ShippingAddres{get;set;}
public string BillingAddress{get;set;}
public DateTime DateOfBirth {get;set;}
}
public class Item2
{
public long customer_id{get;set;}
public string shipping_addres{get;set;}
public string billing_address{get;set;}
public DateTime date_of_birth {get;set;}
}
我試圖尋找答案,但我發現告訴手動映射域所有的答案:
.ForMember(dest => dest.CustomerId, opt => opt.MapFrom(src => src.customer_id));
我不想手動映射每個屬性,因爲我有很多屬性。我想配置一些規則:
由「_」分割財產名並加入字符串駝峯
或僞代碼:
cfg.AddConditionalObjectMapper().Where((source, destination) => s.Name.Replace("(_)([a-z])","\U1") == d.Name);
的問題是不是正則表達式,我需要知道如何在自動映射器中配置這些規則?