Add 增加扩展函数

This commit is contained in:
lihanbo 2024-10-29 15:46:23 +08:00
parent cc23f8b00b
commit 04f8d9e15d
1 changed files with 10 additions and 2 deletions

View File

@ -1,9 +1,9 @@
using System; using LFlow.Base.Interfaces;
using Mapster; using Mapster;
namespace LFlow.Base.Utils; namespace LFlow.Base.Utils;
public class Mapper public static class Mapper
{ {
/// <summary> /// <summary>
/// 将一个对象映射到另一个对象 /// 将一个对象映射到另一个对象
@ -19,4 +19,12 @@ public class Mapper
} }
return source.Adapt<T>(); return source.Adapt<T>();
} }
public static T? MapTo<T>(this IDataModel model)
{
if (model == null)
{
return default;
}
return model.Adapt<T>();
}
} }