/// <summary> /// Executes a query on the database and them returns a entities. /// </summary> /// <param name="connectionString">The connection parameters.</param> /// <param name="sqlSelect">A SQL query to execute.</param> /// <param name="parameters">Parameters collection.</param> /// <returns>A <see cref="System.Data.DataTable">DataTable</see> with results of the query.</returns> public static T[] QueryEntity <T>(ConnectionStringSettings connectionString, string sqlSelect, string baseAlias, params TenorParameter[] parameters) where T : EntityBase { var dataTable = QueryData(connectionString, sqlSelect, parameters); return(Array.ConvertAll <EntityBase, T>(EntityBase.BindRows(dataTable, typeof(T), baseAlias), new Converter <EntityBase, T>(delegate(EntityBase obj) { return (T)obj; }))); }
/// <summary> /// Executes the query defined on this instance. /// </summary> public EntityBase[] Execute(ConnectionStringSettings connection) { if (Top > 0 && eagerLoading.Count > 0) { throw new NotSupportedException("Cannot use eager loading with Top/Limit."); } if (Projections.Count > 0) { throw new NotSupportedException("Cannot use projections without a Linq Query."); } Tenor.Data.DataTable rs = SearchWithDataTable(connection); return(EntityBase.BindRows(rs, this)); }
/// <summary> /// Executes the query defined on this instance respecting skip and take arguments. /// </summary> /// <param name="skip">Number of rows to skip</param> /// <param name="take">Number of rows to take</param> public EntityBase[] ExecuteSkipTake(int skip, int take, ConnectionStringSettings connection) { Tenor.Data.DataTable rs = SearchWithDataTable(connection, false, skip, take); return(EntityBase.BindRows(rs, this)); }