【发布时间】:2018-08-06 13:46:11
【问题描述】:
我有以下控制器方法,其中 AppVersion 包含 Name 中的确切值,以及其他一些字符串,例如 Name: Some Application, AppVersion: Some Application - Production。我需要从 AppVersion 的值中去除 Name 的值。我试图搜索但不确定我在寻找什么。
public IActionResult GetByAppId(string Id)
{
return new JsonResult(_db.Applications
.Select(a => new
{
a.Id,
a.AppId,
a.Name,
a.AppVersion
})
.Where(a => a.Id == Id)
.SingleOrDefault()
);
}
电流输出示例:
Name: Employee Recognition
AppVersion: Employee Recognition - Acceptance
Name: Content Delivery Platform (CDP)
AppVersion: Content Delivery Platform (CDP) - pod 2 - Production
【问题讨论】:
-
为什么是
标签? -
一些当前输出和期望输出的例子会很好。
-
正则表达式是您应该查找的内容。
-
您能否为 AppVersion 提供至少 2 个示例值?
-
不要将查询与
JsonResult调用混用。将结果存储在变量中并修改属性。
标签: c# .net entity-framework linq