小编Ale*_*sev的帖子

IQueryable不实现IDbAsyncEnumerable

该问题最初是在http://entityframework.codeplex.com/discussions/399499#post928179上提出的.

美好的一天!请告诉我发布此问题是否错误.

我有一个查询如下:

IQueryable<Card> cardsQuery =
  dataContext.Cards
  .Where(predicate)
  .OrderByDescending(kc => kc.SendDate)
  .AsQueryable();
Run Code Online (Sandbox Code Playgroud)

然后我尝试:

Task<Card[]> result = cardsQuery.ToArrayAsync();

异常上升:

The source IQueryable doesn't implement IDbAsyncEnumerable<Models.Card>

我使用'EF 5.x DbCotext generator'的修改版本.

怎么避免呢?

UPDATE

重要的是我有生产方法IQuerayble<Card>如下:

class Repository {
  public IQueryable<Card> GetKudosCards(Func<Card, bool> predicate) {
    IEnumerable<KudosCard> kudosCards = kudosCardsQuery.Where(predicate);
     return kudosCards
            .OrderByDescending(kc => kc.SendDate)
            .AsQueryable();
  }
}
Run Code Online (Sandbox Code Playgroud)

entity-framework

6
推荐指数
3
解决办法
1万
查看次数

如何通过q​​uasiquotes或deconstructors匹配`universe#Type`?

我有一个类型resultTypeContext.this.type#c#universe#Type.我需要将它与Unit类型相匹配.我试过了

resultType match {
  case q"Unit" => ...
}
Run Code Online (Sandbox Code Playgroud)

但我想这Unit只是一个字符串文字,显然不匹配.如何通过q​​uasiqotes匹配类型?

我也尝试过

resultType match {
  case TypeRef(ThisType(_), Symbol("scala.Unit"), _) => ...
}
Run Code Online (Sandbox Code Playgroud)

但有一个错误:

[error]  pattern type is incompatible with expected type;
[error]  found   : Symbol
[error]  required: Context.this.c.universe.SymbolContextApi
Run Code Online (Sandbox Code Playgroud)

如何以这种方式匹配类型?

scala scala-macros scala-quasiquotes

4
推荐指数
1
解决办法
419
查看次数

当`B类扩展A`和'L <:A`时,为什么`List [B]`不是`Seq [L]`的子类型?

有:

class A
class B extends A
Run Code Online (Sandbox Code Playgroud)

写是正确的:

val foo: Seq[A] = List[B](new B)
Run Code Online (Sandbox Code Playgroud)

在发生错误时我会错过什么?

def bar[L <: A](): Seq[L] = List[B](new B)
Run Code Online (Sandbox Code Playgroud)

错误:

[error]  found   : List[B]
[error]  required: Seq[L]
[error]     def t[L <: A](): Seq[L] = List[B](new B)
Run Code Online (Sandbox Code Playgroud)

scala scala-collections

2
推荐指数
1
解决办法
120
查看次数