public ActionResult SearchByName(string ss) { string name = ss; XElement res = new XElement("sequense", SObjects.SearchByName(name)); return(new ContentResult { ContentType = "text/xml", Content = res.ToString() }); }
public SearchModel(string searchstring, string type) { DateTime tt0 = DateTime.Now; if (searchstring == null) { searchstring = ""; } this.searchstring = searchstring; //type = "http://fogid.net/o/person"; // для отладки this.type = type; //if (string.IsNullOrEmpty(searchstring)) { _results = new SearchResult[0]; return; } var query = SObjects.SearchByName(searchstring) .Select(xres => { XElement name_el = xres .Elements("field").Where(f => f.Attribute("prop").Value == "http://fogid.net/o/name") .OrderByDescending(n => n.Attribute(ONames.xmllang) == null ? "ru" : n.Attribute(ONames.xmllang).Value) .FirstOrDefault(); string name = name_el == null ? "noname" : name_el.Value; SearchResult res = new SearchResult() { id = xres.Attribute("id").Value, value = name }; XAttribute t_att = xres.Attribute("type"); if (t_att != null) { res.type = t_att.Value; } string tname = ""; if (!string.IsNullOrEmpty(res.type)) { ModelCommon.OntNames.TryGetValue(res.type, out tname); } res.type_name = tname; return(res); }); if (this.type != null) { query = query.Where(res => res.type == this.type); } _results = query .OrderBy(s => s.value) .ToArray(); timespan = DateTime.Now - tt0; message = "duration=" + (timespan.Ticks / 10000L); }