Your
Id
property is a nullable
Guid
, which is not supported by Crystal's
SetDataSource
method.
If the IDs always have a value, then select it:
rpt.SetDataSource(context.TrainingRegs.Select(c => new
{
id = c.Id.Value
}).ToList());
If you want to ignore the IDs which don't have a value, then filter then out:
rpt.SetDataSource(context.TrainingRegs.Where(c => c.Id != null).Select(c => new
{
id = c.Id.Value
}).ToList());
If you need to preserve nulls, then you'll need to convert the value to a
SqlGuid[
^]:
rpt.SetDataSource(context.TrainingRegs.AsEnumerable().Select(c => new
{
id = c.Id == null ? SqlGuid.Null : new SqlGuid(c.Id.Value)
}).ToList());