Пример #1
0
        // Поиск по образцу, содержащему не меньше, чем 4 символа
        public void TestSearch(string ss)
        {
            string name4    = ss.Length <= 4 ? ss : ss.Substring(0, 4);
            int    hs_s4    = name4.ToLower().GetHashCode();
            int    hs_pname = sema2012m.ONames.p_name.GetHashCode();
            var    query    = n4.Root.Elements()
                              .Where(p => (int)((object[])p.Get())[1] == hs_s4)
                              .Select(p => GetEntryByHash((int)((object[])p.Get())[0]).Field(3))
                              .SelectMany(en => en.Elements().Where(en2 => (int)en2.Field(0).Get() == hs_pname))
                              .SelectMany(en2 => en2.Field(1).Elements())
                              .Select(en3 =>
            {
                long off           = (long)en3.Get();
                any_triplet.offset = off;
                return((object[])any_triplet.UElement().Get());
            })
                              .Where(four => (string)four[1] == sema2012m.ONames.p_name && ((string)four[2]).StartsWith(ss))
                              .Select(four => new { id = (string)four[0], name = (string)four[2] });

            Console.WriteLine("TestSearch (id, name): ");
            foreach (var idname in query)
            {
                Console.WriteLine("\t{0} {1}", idname.id, idname.name);
            }
        }