【问题标题】:EntityCollection as parameter in a methodEntityCollection 作为方法中的参数
【发布时间】:2013-01-18 01:29:57
【问题描述】:

我正在尝试编写一个代码,其中 EntityCollection 是方法的参数 但我不知道正确的编码是什么

有人可以帮我解决这个问题吗?

这里是示例代码

 //by the way, this is a wrong coding, I am just showing you, what is the thing that I want to do...
private void sampleMethod(EntityCollection a)
{
   if (a.ToList().Count == 0)
   {
      //body
   }
}

当我调用它时,它就是这个样子

sampleMethod(employee.EducationalBackground);

【问题讨论】:

  • 我无法理解您在寻找什么……正确编码是什么意思?
  • 正确的数据类型/类,例如“employee.EducationalBackrground”,因此我可以将其用作方法中的参数。

标签: c# entity-framework-4 entitycollection


【解决方案1】:

这个问题有点难以理解,但我想你正在寻找这样的东西:

private void sampleMethod(EntityCollection<Employee> employees)
{
   foreach(var employee in employees)
   {
      // do something with every employee.EducationalBackground
   }
}

搜索“c# 泛型”以获取有关 EntityCollection&lt;Employee&gt; 的信息。

搜索“linq”以获取有关如何使用集合的信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-28
    • 1970-01-01
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-30
    相关资源
    最近更新 更多