using Masuit.Tools; using System.ComponentModel.DataAnnotations; namespace WIDESEA_StorageBasicService; public class Dt_InWheels_mes_htyService : ServiceBase, IDt_InWheels_mes_htyService { public Dt_InWheels_mes_htyService(IDt_InWheels_mes_htyRepository BaseDal) : base(BaseDal) { } // 验证模型 public static List ValidateModel(object model) { // 创建一个验证结果列表 var validationResults = new List(); // 创建一个验证上下文 var validationContext = new ValidationContext(model, serviceProvider: null, items: null); // 使用验证器尝试验证模型,并将验证结果添加到验证结果列表中 Validator.TryValidateObject(model, validationContext, validationResults, validateAllProperties: true); // 返回验证结果列表 return validationResults; } }