/// <summary> /// Constrói uma instancia do mapeamento da consulta. /// </summary> /// <param name="name">Nome da consulta.</param> /// <param name="useDatabaseSchema">Identifica se sera usado o esquema do banco de dados para fazer a consulta.</param> /// <param name="returnMapping">Informações sobre o retorno da consulta.</param> /// <param name="query">SQL da consulta.</param> /// <param name="parameters">Parametros usados na consulta.</param> public SqlQueryMapping(string name, bool useDatabaseSchema, SqlQueryReturnMapping returnMapping, string query, IEnumerable <SqlQueryParameterMapping> parameters) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } this.Name = name; this.UseDatabaseSchema = useDatabaseSchema; this.Return = returnMapping; this.Query = query; if (parameters != null) { foreach (var i in parameters) { if (!Parameters.Exists(f => f.Name == i.Name)) { Parameters.Add(i); } } } }
/// <summary> /// Constrói uma instancia do mapeamento da consulta. /// </summary> /// <param name="element"></param> public SqlQueryMapping(XmlElement element) { Name = GetAttributeString(element, "name", true); var boolVal = false; string val = GetAttributeString(element, "use-database-schema", "true"); #if PocketPC if (GDA.Helper.GDAHelper.TryParse(val, out boolVal)) #else if (bool.TryParse(val, out boolVal)) #endif { UseDatabaseSchema = boolVal; } else { UseDatabaseSchema = true; } var parameters = FirstOrDefault <XmlElement>(element.GetElementsByTagName("parameters")); if (parameters != null) { foreach (XmlElement i in parameters.GetElementsByTagName("param")) { var pm = new SqlQueryParameterMapping(i); if (!Parameters.Exists(f => f.Name == pm.Name)) { Parameters.Add(pm); } } } var returnInfo = FirstOrDefault <XmlElement>(element.GetElementsByTagName("return")); if (returnInfo != null) { Return = new SqlQueryReturnMapping(returnInfo); } var commandText = FirstOrDefault <XmlElement>(element.GetElementsByTagName("commandText")); if (commandText != null || !string.IsNullOrEmpty(commandText.InnerText)) { Query = commandText.InnerText.TrimStart('\n', '\t').TrimEnd('\n', '\t'); } }