我想了解如何在 MongoDBdriver 中包含 List 中的特定欄位(任何解決方案)
當我嘗試包含某些屬性時,例如:
var projection = Builders <SomeClass> .Projection
.Include (x => x.Id)
它的作業沒有任何問題。
但是當我嘗試從作業表中包含特定欄位時
var projection = Builders <SomeClass> .Projection
.Include (x => x.ListOfSomeClasses.Select (x => x.SomeProperty))
我得到這個例外
Error occurred during request execution
System.InvalidOperationException: Unable to determine the serialization information for x => x.ListOfSomeClasses.Select (x => x.SomeProperty).
在此之前,我使用過 postgres,那里沒有這樣的問題。
也許 Mongo 在這方面存在一些問題。任何答案都對我很有幫助。謝謝
uj5u.com熱心網友回復:
c# 驅動程式允許對型別化方式不支持的 LINQ 查詢使用原始 MQL:
var projection = Builders<SomeClass>.Projection
.Include("ListOfSomeClasses.SomeProperty");
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/354248.html
