I have an Entity Framerwork API controller that returns a list of objects called 'systems'.
In that object, I have an ICollection property called StarSystems that is a collection of ints that represent string names.
Instead of returning the array of ints, I'd like to return the actual names that those ints represent.
So instead of StarSystems looking like this:
[1, 2, 3] or [1, 3] etc...
it would look like this
["Alpha Zeta III", "Omega System X", "Cygnus X-1"] or ["Alpha Zeta III", "Cygnus X-1"] etc...
So I tried doing this so that it returns the desired string based on the int, but it is giving me this error:
Operator '==' cannot be applied to operands of type 'ICollection<StarSystems>' and 'int'
var systems = await _context.System
.Select(x => new SystemEntity
{
Id = x.Id,
StarSystems = (x.StarSystems == 1) ? "Alpha Zeta III" : (x.StarSystems == 2) ? "Omega System X" : (x.StarSystems == 3) ? "Cygnus X-1",
Title = x.Title,
.ToListAsync();
Is there a way to do this?
Thanks!