20260831功能同步:
1. 不同车间区分料框查询、料框解绑接口 2. 注释电池型号逻辑 3. 打开电池状况界面
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
public static class ModelExtension
|
||||
{
|
||||
public static T ToModel<T>(this System.Data.DataRow row) where T : class, new()
|
||||
{
|
||||
if (row == null) return null;
|
||||
T model = new T();
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
foreach (var prop in properties)
|
||||
{
|
||||
if (row.Table.Columns.Contains(prop.Name))
|
||||
{
|
||||
var value = row[prop.Name];
|
||||
if (value != DBNull.Value)
|
||||
{
|
||||
prop.SetValue(model, Convert.ChangeType(value, prop.PropertyType));
|
||||
}
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user