如何访问另一个类linq中的一个类属性

时间:2012-02-25 10:36:00

标签: c# asp.net .net

  

可能重复:
  how to make an variable accessible to other class(within same csproj)

我有一个变量

int principleIndex = Principles.Instance.RowIndexToPrincipleIndex(hti.Row);

我想在另一个类linq查询中使用它:

principlesList.Select(p => p.GetInstanceForDatabase()).where(p=>p.principleIndex ).ToList()

但此处无法访问principleIndex

我该怎么办?我试图让它静态,我也尝试在属性中使用它,但是不起作用。

1 个答案:

答案 0 :(得分:0)

是否在与第二行代码相同的范围内定义了PrincipleIndex?如果是这样,也许您的Where调用应该读取类似.Where(forDBInstance => forDBInstance.Index == principleIndex)

相关问题