UDT mapping not working for property of another class

Description

I am having issues when i am trying to map like so for a simple class Team with Id and IEnumerable of a UDT called Player. It gives me invalidcastexception saying it can't cast system.byte[][] to IEnumerable<Player>. Is this not the way to map a UDT column?

//############## schema info ################

CREATE TABLE league.team (
team_id int PRIMARY KEY,
players set<frozen<player>>
}

CREATE TYPE league.player (
number int,
description text,
name text
}

//############## Here are the mappings ################

public class CassandraMappings : Cassandra.Mapping.Mappings
{
public CassandraMappings()
{
UdtMap.For<Players>()
.Map(a => a.Number, "number")
.Map(a => a.Description, "description")
.Map(a => a.Name, "name");

For<Team>()
.TableName("team")
.PartitionKey(x => x.Id)
.Column(x => x.Id, cm => cm.WithName("team_id"))
.Column(x => x.Players, cm => cm.WithName("players"));
}
}

//############## Here are the model classes ################

public class Team : IEntity
{
public int Id { get; set; }
public IEnumerable<Player> Players { get; set; }
}

public class Player : IEntity
{
public int Number { get; set; }
public string Description { get; set; }
public string Name { get; set; }
}

//############## interfaces and repository ################

public interface IEntity
{
}

public interface IRepository
{
T Get<T>(Expression<Func<T, bool>> predicate) where T : IEntity;
IEnumerable<T> Find<T>(Expression<Func<T, bool>> predicate) where T : IEntity;
IEnumerable<T> Find<T>() where T : IEntity;
}

public class Repository : IRepository
{
private ISession _session { get; set; }

public Repository(ISession session)
{
_session = session;
}

public T Get<T>(System.Linq.Expressions.Expression<System.Func<T, bool>> predicate) where T : IEntity
{
return Find<T>(predicate).FirstOrDefault();
}

public IEnumerable<T> Find<T>(System.Linq.Expressions.Expression<System.Func<T, bool>> predicate)
where T : IEntity
{
return new Table<T>(_session).Where(predicate).Execute();
}

public IEnumerable<T> Find<T>() where T : IEntity
{
var result = new Table<T>(_session).Execute();
return result;
}
}

//############## example of calling code that throws exception ################

// GET api/team/5
[HttpGet("{id}")]
public object Get(int id)
{
return _repository.Get<Team>(x => x.Id == id);
}

Environment

centos-6.6 Linux
DSE 4.7.0

Activity

Show:
Ross Allen
April 26, 2017, 10:58 PM

figured out my issue. I failed to define my UDTs in the session

Jorge Bay Gondra
April 26, 2017, 11:09 PM

Thanks for letting us know!

If you think that we can improve the docs in any way to make it more clear, feel free to send a pull request or post a comment here.

Not a Problem

Assignee

Unassigned

Reporter

Ross Allen

Labels

None

Reproduced in

None

PM Priority

None

Fix versions

None

External issue ID

None

Doc Impact

None

Reviewer

None

Pull Request

None

Epic Link

None

Sprint

None

Pull Requests

None

Size

None

Components

Affects versions

Priority

Major