For EntityCollection private EntityCollection RetrieveEntityByAttribute(ref IOrganizationService service, string _Entity, string[] _ColumnSet, string[] _AttributeRange, object[] _AttributeValue) { EntityCollection mcs_QueueItemComplaint = null; ColumnSet Indexcol = new ColumnSet(_ColumnSet); QueryByAttribute indexattribute = new QueryByAttribute(); indexattribute.EntityName = _Entity; indexattribute.Attributes.AddRange(_AttributeRange); indexattribute.Values.AddRange(_AttributeValue); indexattribute.ColumnSet = Indexcol; RetrieveMultipleRequest req_index = new RetrieveMultipleRequest(); req_index.Query = indexattribute; RetrieveMultipleResponse resp_index = (RetrieveMultipleResponse)service.Execute(req_index); if (resp_index != null) { mcs_QueueItemComplaint = resp_index.EntityCollection;