CSFrameworkV6试用版开发指南 | GetDataByKey 方法使用与扩展应用|C/S开发框架
GetDataByKey 方法说明
根据主键(如:isid)值获取一条数据。
EF模型的主键定义:

DAL层代码实现
public override dt_AccountItems GetDataByKey(string keyValue)
{
return _Database.GetQueryable<dt_AccountItems>()
.Where(w => w.isid == keyValue).FirstOrDefault();
}
注意 where 条件:

扩展需求
如用户输入 ItemID 【会计科目编码】需要校验数据是否存在,使用GetDataByKey是不行的,需要扩展一个方法,如:GetDataByItemId

dt_AccountItems 表

什么是 isid ?
isid = Is Identity的缩写。在开发框架领域,isid 表示 记录主键,任何一张表需要定义isid字段。值全局唯一,可以使用雪花id 或 GUID。前端界面新增记录时默认赋值雪花id或GUID,若前端没有赋值,框架会自动设置为雪花id。
扫一扫加作者微信