c# - 如何在 c# 中创建扩展以返回可以在 linq 中转换为实体的新日期时间条目?
问题描述
所以我在 LinQ to entity 查询中有这个属性,我需要给它添加天数
isWithinNinetyDays = (a.ParcelData == null ? false :
(a.ParcelData.Parcel_LetterTracking == null ? false :
(a.ParcelData.Parcel_LetterTracking.LMailDate == null ? false :
(System.Data.Entity.DbFunctions.AddDays(a.DateTimeEntry, 90) >= a.ParcelData.Parcel_LetterTracking.LMailDate.Value)))),
问题是我不想使用“System.Data.Entity.DbFunctions.AddDays(a.DateTimeEntry, 90)”,因为我将不得不这样做很多,而且每次都这么写太难看了。 ..是否可以在我可以打电话的地方进行分机
a.DateTimeEntry.MyExtension(90)
that will add 90 days and be able to convert it to a entity convertable to sql object?
解决方案
使用using
声明。
using System.Data.Entity;
DBFunctions.AddDays(a.DateTimeEntry, 90) ...
推荐阅读
- amazon-web-services - 如何在 AWS Connect 聊天 UI 中更改显示名称
- javascript - 如果设备是华为?
- android - 两个 TextView 并排 - 两个 TextView 都应该尽可能多地占用空间
- python - Python字典是否适合高并发的只读数据库的缓存解决方案?
- css - 如何在 sass 中修改 MDBReact 组件中的伪元素?
- sql - 如何用 ORDER BY OR GROUP BY 表示树结构
- lua - 如何制作一个 if 语句来检查是否已单击某个部分(roblox lua)
- laravel - Laravel - 请求安全方法不存在
- spring-boot - 类型参数“S”的推断类型“S”不在其范围内;应该延长
- php - PHP将相同的字符串附加到一行中的多个其他字符串?