【发布时间】:2019-04-05 12:04:20
【问题描述】:
从 MT_Vehicle 中选择 count(distinct LicencePlate),其中 IsDeleted=0 且 CreatedBy = 1
【问题讨论】:
标签: sql linq linq-to-sql distinct
从 MT_Vehicle 中选择 count(distinct LicencePlate),其中 IsDeleted=0 且 CreatedBy = 1
【问题讨论】:
标签: sql linq linq-to-sql distinct
你可以这样写:
var count = db.MT_Vehicle
.Where( v => v.IsDeleted == 0 && v.CreatedBy == 1 )
.Select(v => v.LicencePlate)
.Distinct()
.Count();
【讨论】:
var count = MT_Vehicle.Where(x => x.IsDeleted==0 && x.CreatedBy == 1)
.Select(x => x.LicencePlate)
.Distinct()
.Count();
【讨论】: