MongoDBで複数の文書に参加したい。私は次のコードを使用していますが、動作しません。私は何か間違って考えましたか? Idを含む基本エンティティモデルを追加しました。複数のドキュメントに参加するには?
var products = _productRepository.GetCollection(_dbContext);
var prodWarhoseMapping = _productWarehouseMapRepository.GetCollection(_dbContext);
var warhouses = _warehouseRepository.GetCollection(_dbContext);
public class Product:BaseEntity
{
public string product_code { get; set; }
public decimal fat_tax { get; set; }
}
public class ProductWarehouseMap :BaseEntity
{
public ObjectId product_id { get; set; }
public ObjectId warehouse_id { get; set; }
public int qty { get; set; }
public decimal price { get; set; }
}
public class Warehouse :BaseEntity
{
public ObjectId supplier_id { get; set; }
public string warehouse_code { get; set; }
public string name { get; set; }
public string email { get; set; }
public string phone { get; set; }
public string street_address { get; set; }
public string city { get; set; }
public string postal_code { get; set; }
public string region { get; set; }
public string country { get; set; }
public string manager_name { get; set; }
public string fax { get; set; }
}
//works proper
var query1 = (from p in products
join pm in prodWarhoseMapping on p._id equals pm.product_id
select new
{
Products = p,
ProductMapping = pm,
}).ToList();
//Getting error
var query = (from p in products
join pm in prodWarhoseMapping on p._id equals pm.product_id
join wh in warhouses on pm.warehouse_id equals wh._id
select new
{
Products = p,
ProductMapping = pm,
Warehouse = wh
}).ToList();
ベローは、私はベローはエラーメッセージタイプの
式「ですSystem.Collections.Generic.IEnumerable
public class BaseEntity
{
[BsonIgnoreIfDefault]
public ObjectId _id { get; set; }
}
ベースのエンティティモデルを追加するのを忘れ基本エンティティ です1[Project.Communication.EntityModels.ProductWarehouseMap]' cannot be used for parameter of type 'System.Linq.IQueryable
1メソッド[System.Linq.IQueryableの[Project.Communication.EntityModels.ProductWarehouseMap] '1[Project.Communication.EntityModels.ProductWarehouseMap] Where[ProductWarehouseMap](System.Linq.IQueryable
1 [Projec t.Communication.EntityModels.ProductWarehouseMap]、System.Linq.Expressions.Expression 1[System.Func
2 [Project.Communication.EntityModels.ProductWarehouseMap、可能System.Boolean]])は、」 パラメータ名:arg0に
私たちは、例えば、あなたを助けるために*エラーを取得*以上が必要になりますエラーメッセージ/コード。また、 '_id'プロパティはあなたのクラス定義には見当たりません。 –
@ KeyurPATEL上記のコードをチェックしてください。idを含む基本エンティティモデルが追加されました。 –
もう一度、エラーメッセージ/コードが参考になるでしょう。 '_id'の定義は良く見えます。 –