Skip to content

Property 'Street' is not defined for type 'System.String' then sorting #6478

@dvdobrovolskiy

Description

@dvdobrovolskiy

I have an issue then I try to sort by field from subquery

here is code

model.Contacts = await _context.Apartments.Select(s => new ContactsVM
            {
                ApartmentId = s.ApartmentId,
                **Address = _context.Blocks.SingleOrDefault(b => b.BlockId == s.BlockId).Street,**
                Number = s.Number,
                Floor = s.Floor,
                Entrance = s.Entrance,
                MainPhone = s.MainPhone,
                SecondaryPhone = s.SecondaryPhone,
                TertiaryPhone = s.TertiaryPhone,
                QuaternaryPhone = s.QuaternaryPhone,
                QuinaryPhone = s.QuinaryPhone,
                SenaryPhone = s.SenaryPhone,
                SeptenaryPhone = s.SeptenaryPhone,
                OctonaryPhone = s.OctonaryPhone,
                NonaryPhone = s.NonaryPhone,
                DenaryPhone = s.DenaryPhone
            })
            **.OrderBy(o => o.Address)**
            .Skip(offset)
            .Take(DefaultPageSize)
            .ToListAsync();

and I get
ArgumentException: Property 'System.String Street' is not defined for type 'System.String'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions