考虑以下记录:
概述的记录是相同的游戏对象,但它们具有不同的配置名称(ConfigurationName 为空的记录是我原始表的副本)。
string customName= "Config1";
string draftName = "Draft_" + id;
var list = db.JoinedGameObjects
.Where(x => x.TBUploads_ID == id)
.Where(x => x.ConfigurationName.Equals(customName) || x.ConfigurationName == null)
.Select(x => new GameObjectViewModel()
{
ID = x.ID,
GameObjectName = x.GameObjectName,
Category = x.Category,
Family = x.Family,
Type = x.Type,
MetaTypeJson = x.MetaTypeJson,
MaterialsJson = x.MaterialsJson,
MetadataVisibilityJson = x.MetadataVisibilityJson,
Visible = x.joined_Visible ?? x.Visible
}).ToList();
此代码获取 ConfigurationName 等于我的 customName 变量或 ConfigurationName = null 的所有记录。然而,这不是我想要的。
我将尝试用一个例子来解释预期的结果。
我首先要检查是否存在此 ID 的 ConfigurationName 等于 DraftName 的记录(如果为 true,则选择此记录),如果没有,则检查是否存在此 ID 且 ConfigurationName 等于 customName 的记录(如果为 true,则选择此游戏对象),如果不采用此 ID 的记录,其中 ConfigurationName 为空。
有人可以指导我正确的方向或提供一个可行的例子吗?