2016-08-05 12 views
3

저는 Cassandra의 초보자이며 linq를 사용하여 Cassandra 데이터베이스의 일반 저장소를 만들었습니다. 내 Single() 메소드의 경우 매개 변수로 where 조건을 전달합니다.Cassandra : 인수 유형이 일치하지 않습니다.

이 내 단일 방법 : 이것은이 하나의 메소드를 호출하는 방법입니다

public async Task<T> Single(Expression<Func<T, bool>> exp) 
{ 
    return await GetTable.Where<T>(exp).FirstOrDefault().ExecuteAsync(); 
} 

카산드라 데이터베이스를 쿼리하는 데 사용하고있는 LINQ 코드가

Single(Expression<Func<T, bool>> exp) 

public override Task OnConnected() 
{ 
    if (Context.User != null) 
    { 
     string userName = Context.User.Identity.Name; 

     this.Groups.Add(userName, Context.ConnectionId); 

     ***** this is the line with the issue ****** 
     Notification notification = Task.Run(() => _notificationRepository.Single(x => x.UserName.Equals(userName))).Result; 

     if (notification == null) 
     { 
      _notificationRepository.CreateInstance(new NotificationUserMapping { Connections = new string[] { Context.ConnectionId }, UserName = Context.User.Identity.Name }); 
     } 
     else if (!notification.Connections.Contains(Context.ConnectionId)) 
     { 
      notification.Connections.Add(Context.ConnectionId); 
      _notificationRepository.Save(notification); 
     } 
    } 

    return base.OnConnected(); 
} 

"인수 유형이 일치하지 않습니다"라는 "System.AggregateException"이 계속 표시되어 혼동합니다. 이것이 어디에서 왔는지.

데이터베이스 테이블 컬럼 :

id uuid PRIMARY KEY, 
connections list<text>, 
username text 

와 C#을 마시고 :

[Table(ExplicitColumns = true)] 
public class ConnectionMapping 
{ 
    [Column("id")] 
    public Guid Id { get; set; } 
    [Column("connections")] 
    public IList<string> Connections { get; set; } 
    [Column("username")] 
    public string UserName { get; set; } 
} 

과 예외 : 내가 놓친 게 무엇

at System.Linq.Expressions.Expression.Condition(Expression test, Expression ifTrue, Expression ifFalse) 
    at Cassandra.Mapping.MapperFactory.GetExpressionToGetColumnValueFromRow(ParameterExpression row, CqlColumn dbColumn, Type pocoDestType) 
    at Cassandra.Mapping.MapperFactory.CreateMapperForPoco[T](RowSet rows, PocoData pocoData) 
    at Cassandra.Mapping.MapperFactory.CreateMapper[T](RowSet rows) 
    at Cassandra.Mapping.MapperFactory.<>c__DisplayClass1`1.<GetMapper>b__0(Tuple`2 _) 
    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) 
    at Cassandra.Mapping.MapperFactory.GetMapper[T](String cql, RowSet rows) 
    at Cassandra.Mapping.Mapper.<>c__DisplayClass7`1.<FetchAsync>b__6(Statement s, RowSet rs) 
    at Cassandra.Mapping.Mapper.<>c__DisplayClass2`1.<>c__DisplayClass4.<ExecuteAsyncAndAdapt>b__1(Task`1 t2) 
    at Cassandra.Tasks.TaskHelper.DoNext[TIn,TOut](Task`1 task, Func`2 next) 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at CompanyNamespace.CompanyDomain.NotificationRepository.<SingleByUserName>d__0.MoveNext() 

. 나는 그 문서들을 드러냈다. Cassandra와 C# 사이의 매핑 규칙은 정확합니다.

+0

전체적인 방법을 보여줄 수 있습니까? 작은 스 니펫을 제공 할 때를 말하기는 어렵습니다. – DavidG

+0

받은 AggregateException 안에있는 예외에 대한 스택 추적을 추가 할 수 있습니까? 올바른 방향으로 우리를 지적 할 수 있습니다. –

답변

2

몇 가지 실험을 통해 대답을 찾았습니다. Cassandra 목록 기반 컬렉션이 C# 목록에 매핑되지 않는다는 것을 알게되면 대신 C# IEnumerable 객체에 매핑됩니다.