// static csCountry GetCountry(Session ses, String name) { if (String.IsNullOrEmpty(name.Trim())) { name = "НЕОПРЕДЕЛЕННАЯ"; } csCountry rc = null; XPQuery <csCountry> Countrys = new XPQuery <csCountry>(ses); var qc = from pe in Countrys where pe.NameRuShortLow == name select pe; foreach (csCountry pi in qc) { rc = pi; break; } if (rc == null) { rc = new csCountry(ses); rc.NameRuShortLow = name; rc.Save(); } return(rc); }