public LookupFieldResult LookupField(LookupFieldQuery query) { DisableCaching(); var result = new LookupFieldResult { Page = query.Page, Items = new List <LookupFieldResultItem>() }; try { result.Page = query.Page; var queryTerm = query.Query.ToSafeString().ToLowerInvariant(); var field = (SPContext.Current.SPList(query.ListId.ToGuid()).FieldById(query.FieldId.ToGuid()) as RosterTableLookupField); if (field != null) { var content = new RosterDataService().TableContent(field.TableName, field.KeyName, field.FieldName). Where(i => i.Item2.ToSeparatedString().ToLowerInvariant().Contains(queryTerm)).OrderBy(e => e.Item2.ToSeparatedString()); content.Take(PageSize).Skip(PageSize * result.Page).ToList().ForEach(item => { var resultItem = new LookupFieldResultItem { id = item.Item1, name = item.Item2.FirstValue(), }; ((List <LookupFieldResultItem>)result.Items).Add(resultItem); }); } } catch (SqlException ex) { if (!ex.Message.Contains("Conversion failed")) { HandleException(ex); } } catch (Exception ex) { HandleException(ex); } return(result); }