Lambda表达式与空paren()

Cem*_*mre 7 c# linq lambda

我遇到的代码如下:

var vpAlias = null;
var prices = session.QueryOver<Vehicle>()
    .Left.JoinAlias<VehiclePrice>(x => x.VehiclePrice, () => vpAlias, x => x.VehiclePriceTypeId == 1)
    .Where(() => vpAlias.Id == null || vpAlias.VehiclePriceTypeId == 1)
    .Select(x => x.Id, () => vpAlias.Price)
    .ToList();
Run Code Online (Sandbox Code Playgroud)

使用()在其lambda表达式.那是什么意思 ?它是否仅用作占位符?

Jon*_*eet 16

它只是意味着它是一个空参数列表 - 对于没有任何参数的委托类型.

你可以写的这个事实x => x.Id只是一个简写(x) => x.Id,反过来又是一个简写(Vehicle x) => x.Id.它只是一个参数列表.