public static CountryCode Load(Guid Id) { bool success = false; CountryCode result = new CountryCode (); QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table (DatabaseTableName); qb.Columns ( "id", "createtimestamp", "updatetimestamp", "name", "alternativnames", "dialcodes" ); qb.AddWhere ("id", "=", Id); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { if (query.NextRow ()) { result._id = query.GetGuid (qb.ColumnPos ("id")); result._createtimestamp = query.GetInt (qb.ColumnPos ("createtimestamp")); result._updatetimestamp = query.GetInt (qb.ColumnPos ("updatetimestamp")); result._name = query.GetString (qb.ColumnPos ("name")); result._alternativnamesasstring = query.GetString (qb.ColumnPos ("alternativnames")); result._dialcodesasstring = query.GetString (qb.ColumnPos ("dialcodes")); success = true; } } query.Dispose (); query = null; qb = null; if (!success) { throw new Exception (string.Format (Strings.Exception.CountryCodeLoad, Id)); } return result; }
public static List<Range> List(CountryCode countrycode) { List<Range> result = new List<Range> (); QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table (DatabaseTableName); qb.Columns ("id"); if (countrycode != null) { qb.AddWhere ("countrycodeid", "=", countrycode.Id); } Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { while (query.NextRow ()) { try { result.Add (Load (query.GetGuid (qb.ColumnPos ("id")))); } catch {} } } query.Dispose (); query = null; qb = null; return result; }
public static CountryCode FromXmlDocument(XmlDocument xmlDocument) { Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument); CountryCode result; if (item.ContainsKey ("id")) { try { result = CountryCode.Load (new Guid ((string)item["id"])); } catch { result = new CountryCode (); result._id = new Guid ((string)item["id"]); } } else { result = new CountryCode (); } if (item.ContainsKey ("name")) { result.Name = (string)item["name"]; } if (item.ContainsKey ("dialcodes")) { try { result._dialcodes.Clear (); foreach (XmlDocument dialcode in (List<XmlDocument>)item["dialcodes"]) { result._dialcodes.Add ((string)((Hashtable)SNDK.Convert.FromXmlDocument (dialcode))["value"]); } } catch {} } if (item.ContainsKey ("alternativnames")) { try { result._alternativnames.Clear (); foreach (XmlDocument alternativname in (List<XmlDocument>)item["alternativnames"]) { result._alternativnames.Add ((string)((Hashtable)SNDK.Convert.FromXmlDocument (alternativname))["value"]); } } catch {} } return result; }