score:1

Accepted answer

that's should what you are looking for : (i love to use string.isnullorempty rather than cmp string.empty)

_targethasmissingratings = _existingratings.any(er => string.isnullorempty(_targetratings.firstordefault(tr => er.ratingtypeid == tr.ratingtypeid)?.rating));

score:1

use icomparable so you can use orderby on the entire class or simply compare two instances of the class.

list<ratingdto> ordered = _existingratings.orderby(x => x).tolist();

see code below :

    class ratingdto : icomparable<ratingdto>
    {
        public int ratingtypeid { get; set; }
        public string ratingtype { get; set; }
        public string rating { get; set; }

        public int compareto(ratingdto  other)
        {
            if (this.ratingtypeid != other.ratingtypeid)
            {
                return this.ratingtypeid.compareto(other.ratingtypeid);
            }
            else
            {
                return this.ratingtype.compareto(other.ratingtype);
            }
        }
    }

code would look like this :

            list<ratingdto> _existingratings = new list<ratingdto>(); 
            list<ratingdto> _targetratings = new list<ratingdto>();
            boolean _targethasmissingratings = false;

            foreach (var existing in _existingratings)
            {
                foreach (var target in _targetratings)
                {
                    if (existing == target)
                    {
                         _targethasmissingratings = true;
                         break;
                    }
                }
                if (_targethasmissingratings == true) break;
            }

Related Query