コード例 #1
0
ファイル: DbEngine.cs プロジェクト: rahulchrty/badr-project
        public virtual long SelectCount(IModel model, Queryset queryset = null)
        {
            if (model != null)
            {
                string sCountSql = string.Format("SELECT COUNT(1) FROM {0} as {1}{2}{3}",
                                    model.ModelDbName,
                                    model.ModelDbAlias,
                                    queryset != null ? queryset.GetJoins(this): "",
                                    queryset != null ? queryset.GetWhereClause(this) : "");

                object res = ExecuteScalar(sCountSql, queryset != null ? queryset.GetParamsList() : null);

                long count;
                if (res != null && Int64.TryParse(res.ToString(), out count))
                    return count;
            }

            return -1;
        }
コード例 #2
0
ファイル: DbEngine.cs プロジェクト: rahulchrty/badr-project
        protected string GenerateSelectQuery(string fieldsList, IModel model, Queryset queryset)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("SELECT ");
            sb.Append(fieldsList);
            sb.Append(" FROM ");
            sb.Append(model.ModelDbName + " as " + model.ModelDbAlias);
            if (queryset != null && !queryset.IsEmpty)
            {
                sb.Append(queryset.GetJoins(this));
                sb.Append(queryset.GetWhereClause(this));
                sb.Append(queryset.GetOrderByClause());
                sb.Append(ToSqlLimit(queryset.LimitOffset, queryset.LimitCount));
            }

            return sb.ToString();
        }
コード例 #3
0
ファイル: DbEngine.cs プロジェクト: rahulchrty/badr-project
        public virtual bool Delete(IModel model, Queryset queryset)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("DELETE FROM ");
            sb.Append(model.ModelDbName + " as " + model.ModelDbAlias);
            if (queryset != null && !queryset.IsEmpty)
            {
                sb.Append(queryset.GetJoins(this));
                sb.Append(queryset.GetWhereClause(this));
            }

            ExecuteNonQuery(sb.ToString(), queryset != null ? queryset.GetParamsList() : null);
            return true;
        }