我有扩展方法:
public static IQueryable<TResult> WithFieldLike<TResult>(
this IQueryable<TResult> query,
Func<TResult, string> field,
string value)
{
Expression<Func<TResult, bool>> expr =
trans => field(trans).Contains(value);
return query.Where(expr);
}
Run Code Online (Sandbox Code Playgroud)
我需要更改参数字段来键入:Expression>.会是这样的.
public static IQueryable<TResult> WithFieldLike<TResult>(
this IQueryable<TResult> query,
Expression<Func<TResult, string>> field,
string value)
{
Expression<Func<TResult, bool>> expr = ???
return query.Where(expr);
}
Run Code Online (Sandbox Code Playgroud)
这种方法的调用是:
var query7 = query.WithFieldLike(trans => trans.DeviceModelNumber, "ber_3");
Run Code Online (Sandbox Code Playgroud)
在这种情况下我应该如何构建"expr"?请帮忙.
我正在使用带有“安装后启动应用程序”复选框的WiX进行安装。目标是对设置复选框和取消设置复选框有反应。如果选中了此复选框,则需要运行一个应用程序。如果未设置该复选框,则需要使用命令行参数运行相同的应用程序。
这是我的WiX脚本的一部分。
<CustomAction Id="StartConfigManagerOnExit"
FileKey="ParamsShower.exe"
ExeCommand=""
Execute="immediate"
Impersonate="yes"
Return="asyncNoWait" />
<CustomAction Id="StartUpgradeConfigOnExit"
FileKey="ParamsShower.exe"
ExeCommand="/upgrade"
Execute="immediate"
Impersonate="yes"
Return="asyncNoWait" />
<UI>
<Publish Dialog="ExitDialogEx"
Control="Finish"
Order="1"
Event="DoAction"
Value="StartConfigManagerOnExit">LAUNCHAPPONEXIT = 1</Publish>
<Publish Dialog="ExitDialogEx"
Control="Finish"
Order="1"
Event="DoAction"
Value="StartUpgradeConfigOnExit">LAUNCHAPPONEXIT = 0</Publish>
<Publish Dialog="ExitDialogEx"
Control="Finish"
Event="EndDialog"
Value="Return"
Order="999">1</Publish>
<Dialog Id="ExitDialogEx"
Width="370"
Height="270"
Title="[ProductName] Setup">
<Control Id="LaunchCheckBox"
Type="CheckBox"
X="135"
Y="190"
Width="220"
Height="40"
Property="LAUNCHAPPONEXIT"
Hidden="yes"
CheckBoxValue="1"
Text="Launch an app">
<Condition Action="show">NOT Installed</Condition>
</Control>
</Dialog>
<InstallUISequence>
<Show Dialog="ExitDialogEx"
OnExit="success" />
</InstallUISequence>
<AdminUISequence>
<Show Dialog="ExitDialogEx"
OnExit="success" />
</AdminUISequence>
</UI>
Run Code Online (Sandbox Code Playgroud)
设置LaunchCheckBox时,安装会启动应用程序。但是如果未设置复选框,它不会运行。