誰かが私を助けることができますか?私はこの問題の解決に多くの時間を費やしていないし、何も要素 'group'はGillie.JobCenter.Domain.KeyValueEntityクラスのフィールドまたはプロパティと一致しません
を、これはMongoDBのコレクションの構造である:これは私の実体であるとオブジェクトを助けた
:
public class Course
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public ObjectId Id { get; set; }
[BsonRepresentation(BsonType.ObjectId)]
[BsonElement("_etag")]
public ObjectId Etag { get; set; }
[BsonElement("group")]
public KeyValueEntity<string> Group { get; set; }
[BsonElement("values")]
public GroupValuesCourse[] Values { get; set; }
}
public class KeyValueEntity<T>
{
[BsonElement("key")]
[JsonProperty("key")]
public string Key { get; set; }
[BsonElement("value")]
[JsonProperty("value")]
public T Value { get; set; }
public override string ToString()
{
return Value?.ToString();
}
}
public class GroupValuesCourse
{
[BsonElement("group")]
public KeyValueEntity<string> GroupKeys { get; set; }
[BsonElement("values")]
public KeyValueEntity<string>[] ValueKeys { get; set; }
}
そして、私のレポジトリ
public async Task<IEnumerable<KeyValueEntity<string>>> GetAllForGroupAsync(string groupName, string subGroupName)
{
return await mongoDbContext.MongoDataBase.GetCollection<Course>("courses").AsQueryable()
.Where(courseGroup => courseGroup.Group.Value == groupName)
.SelectMany(courseGroups => courseGroups.Values)
.Where(subgroup => subgroup.GroupKeys.Value == subGroupName)
.SelectMany(groups => groups.ValueKeys)
.OrderBy(value => value.Value)
.ToListAsync();
}
実行した後、これを教えてください:System.FormatException:要素 'group'がGillie.JobCenter.Domain.KeyValueEntity`1 [[System.String、System.Private.CoreLib、Version = 4.0.0.0、Culture =ニュートラル、PublicKeyToken = 7cec85d7bea7798e]]。 しかし、私はマッピングが正しいと確信しています。誰かが私に間違いを見つけるのを助けることができますか?
あなたの投稿を誹謗中傷しないでください。 – Glorfindel
私はそれを削除する必要があります –
@DimaGrigorievあなたはありません。これをStack Overflowに掲載することで、これを公的にライセンスすることに同意しました。 – Adriaan