internal string BuildFetch <T>(string entityName, string[] additionalFilters, List <LinkEntityData> linkedEntities) where T : BaseModel { string filter = null; string filter2 = null; string links = null; string attributes = null; string paging = null; attributes = BaseModel.SelectAttributes <T>(Request.Query["fields"]); try { filter = BaseModel.BuildFilter(typeof(T), Request.Query["filter"]); filter2 = BaseModel.BuildFilter(typeof(T), new StringValues(additionalFilters)); } catch (InvalidFilterFieldException e) { exceptions.Add(e); } if (linkedEntities != null && linkedEntities.Count > 0) { links = BuildLinkEntity <T>(linkedEntities); } try { paging = BaseModel.BuildPaging <T>(Request.Query["limit"], Request.Query["offset"]); } catch (InvalidFilterFieldException e) { exceptions.Add(e); } var fetch = $@"<fetch{paging}> <entity name='{entityName}'> {attributes} {filter} {filter2} {links} </entity> </fetch>"; return(Uri.EscapeDataString(fetch)); }