public IEnumerable <dynamic> Query(object enumQuery, object parameters) { using var connection = _sessionBuilder.GetConnection(); var sql = _resourceManager.GetString($"{SqlQueryAttribute.Get(enumQuery)}"); return(connection.Query(sql, parameters)); }
public QueryString(QueryProvider provider) { SqlQueryAttribute sqlQueryAttribute = typeof(T).GetTypeInfo().GetCustomAttribute <SqlQueryAttribute>(); if (sqlQueryAttribute == null) { throw new Exception($"Generic type {nameof(T)} must define {nameof(SqlQueryAttribute)} to be used with {nameof(QueryString<T>)} class."); } if (provider == null) { throw new ArgumentNullException(nameof(provider)); } QueryProvider = provider; SQLPredicate.Sql = sqlQueryAttribute.Query; Predicate = Expression.Constant(this); if (typeof(T).GetInterfaces().Contains(typeof(IEntity))) { GetTableData(); } }
/// <summary> Write a SqlQuery XML Element from attributes in a member. </summary> public virtual void WriteSqlQuery(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, SqlQueryAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "sql-query" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_SqlQuery_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <resultset-ref> if(attribute.ResultSetRef != null) writer.WriteAttributeString("resultset-ref", GetAttributeValue(attribute.ResultSetRef, mappedClass)); // Attribute: <flush-mode> if(attribute.FlushMode != FlushMode.Unspecified) writer.WriteAttributeString("flush-mode", GetXmlEnumValue(typeof(FlushMode), attribute.FlushMode)); // Attribute: <cacheable> if( attribute.CacheableSpecified ) writer.WriteAttributeString("cacheable", attribute.Cacheable ? "true" : "false"); // Attribute: <cache-region> if(attribute.CacheRegion != null) writer.WriteAttributeString("cache-region", GetAttributeValue(attribute.CacheRegion, mappedClass)); // Attribute: <fetch-size> if(attribute.FetchSize != -9223372036854775808) writer.WriteAttributeString("fetch-size", attribute.FetchSize.ToString()); // Attribute: <timeout> if(attribute.Timeout != -1) writer.WriteAttributeString("timeout", attribute.Timeout.ToString()); // Attribute: <cache-mode> if(attribute.CacheMode != CacheMode.Unspecified) writer.WriteAttributeString("cache-mode", GetXmlEnumValue(typeof(CacheMode), attribute.CacheMode)); // Attribute: <read-only> if( attribute.ReadOnlySpecified ) writer.WriteAttributeString("read-only", attribute.ReadOnly ? "true" : "false"); // Attribute: <comment> if(attribute.Comment != null) writer.WriteAttributeString("comment", GetAttributeValue(attribute.Comment, mappedClass)); // Attribute: <callable> if( attribute.CallableSpecified ) writer.WriteAttributeString("callable", attribute.Callable ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); // Write the content of this element (mixed="true") writer.WriteString(attribute.Content); writer.WriteEndElement(); }
public IEnumerable <dynamic> Query(object enumQuery, object parameters) { var sql = _resourceManager.GetString($"{SqlQueryAttribute.Get(enumQuery)}"); return(_connection.Query(sql, parameters)); }
public IEnumerable <T> Query <T>(object enumQuery, object parameters) { return(_connection.Query <T>(_resourceManager.GetString($"{SqlQueryAttribute.Get(enumQuery)}"), parameters)); }