public T SingleOrDefaultWithParams <T>(string tableName, string whereQuery = null, dynamic extraParams = null, string extraJoins = null, string extraSelect = null, string customOrderBy = null)
        {
            string selectPart = "top(1) " + tableName + ".*";

            if (!String.IsNullOrWhiteSpace(extraSelect))
            {
                selectPart += ", " + extraSelect;
            }

            string joins = "";

            if (!String.IsNullOrWhiteSpace(extraJoins))
            {
                joins = extraJoins;
            }

            string query = @"select " + selectPart + " from " + tableName + " " + joins;

            if (!String.IsNullOrEmpty(whereQuery))
            {
                query = query + " " + whereQuery;
            }

            if (!String.IsNullOrEmpty(customOrderBy))
            {
                query += " order by " + customOrderBy;
            }

            var queryParams = new { };

            var finalParams = SqlServerServices.Combine(queryParams, extraParams != null ? extraParams : new { });

            return(this.SingleOrDefault <T>(query, (object)finalParams));
        }
        public IList <T> ListWithParams <T>(string tableName, int?topLimit = null, string whereQuery = null, dynamic extraParams = null, string extraJoins = null, string extraSelect = null, string customOrderBy = null)
        {
            string selectPart;

            if (topLimit.HasValue)
            {
                selectPart = "top(" + topLimit.Value + ") " + tableName + ".*";
            }
            else
            {
                selectPart = tableName + ".*";
            }

            if (!String.IsNullOrWhiteSpace(extraSelect))
            {
                selectPart += ", " + extraSelect;
            }

            string joins = "";

            if (!String.IsNullOrWhiteSpace(extraJoins))
            {
                joins = extraJoins;
            }

            string query = @"select " + selectPart + " from " + tableName + " " + joins;

            if (!String.IsNullOrEmpty(whereQuery))
            {
                query = query + " " + whereQuery;
            }

            if (!String.IsNullOrEmpty(customOrderBy))
            {
                query += " order by " + customOrderBy;
            }

            var queryParams = new { };

            var finalParams = SqlServerServices.Combine(queryParams, extraParams != null ? extraParams : new { });

            return(this.List <T>(query, (object)finalParams).ToList());
        }