0
public class Actor
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual string ShortName { get; set; }
public virtual IList<BankAccount> BankAccounts { get; set; }
}
public class BankAccount
{
public virtual int Id { get; set; }
public virtual string IbanPrefix { get; set; }
public virtual string Number { get; set; }
}
public class BankAccountModel
{
public int Id { get; set; }
public string IbanPrefix { get; set; }
public string Number { get; set; }
}
public BankAccountModel[] BankAccounts { get; set; }
我想使用linq查詢來選擇特定actor ID的數組BankAccounts屬性中的所有bankaccounts。Linq Query for expected result
我已經試過如下
var query = Repository.Query<Actor>().Where(a => a.Id == parameters.ActorId)
.Select(a => a.BankAccounts);
BankAccounts = query.Select(account => account.Select(a=>
new BankAccountModel
{
Description = a.Description,
IbanPrefix = a.IbanPrefix,
Id = a.Id,
Number = a.Number
}).ToArray());
但它不是爲我工作。