• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Data.UCDbContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UCsoft.Data.UCDbContext的典型用法代码示例。如果您正苦于以下问题:C# UCDbContext类的具体用法?C# UCDbContext怎么用?C# UCDbContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UCDbContext类属于UCsoft.Data命名空间,在下文中一共展示了UCDbContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExistsViewEntity

 /// <summary>
 /// 是否存在该记录
 /// </summary>
 /// <returns></returns>
 public bool ExistsViewEntity(Expression<Func<VCustomerContact , bool>> predicate)
 {
     using (UCDbContext db=new UCDbContext())
     {
        bool status= db.VCustomerContacts.Any(predicate);
        return status;
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:12,代码来源:VCustomerContactDaoImpl.cs


示例2: ExistsViewEntity

 /// <summary>
 /// 是否存在该记录
 /// </summary>
 /// <returns></returns>
 public bool ExistsViewEntity(Expression<Func<VSysDepartment , bool>> predicate)
 {
     using (UCDbContext db=new UCDbContext())
     {
        bool status= db.VSysDepartments.Any(predicate);
        return status;
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:12,代码来源:VSysDepartmentDaoImpl.cs


示例3: ExistsViewEntity

 /// <summary>
 /// 是否存在该记录
 /// </summary>
 /// <returns></returns>
 public bool ExistsViewEntity(Expression<Func<VCompanyUser , bool>> predicate)
 {
     using (UCDbContext db=new UCDbContext())
     {
        bool status= db.VCompanyUsers.Any(predicate);
        return status;
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:12,代码来源:VCompanyUserDaoImpl.cs


示例4: GetViewCount

 /// <summary>
 /// 获取数据总数
 /// </summary>
 /// <returns>返回所有数据总数</returns>
 public int GetViewCount()
 {
     using (UCDbContext db=new UCDbContext())
     {
      var models= db.VCompanyUsers;
      var sqlText = models.GetProperty("SqlText");
      LogHelper.Debug(sqlText.ToString());
      return models.Count();
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:14,代码来源:VCompanyUserDaoImpl.cs


示例5: GetViewEntity

 /// <summary>
 /// 获取指定的单个实体
 /// 如果不存在则返回null
 /// 如果存在多个则抛异常
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 /// <returns>Entity</returns>
 public VCompanyUser GetViewEntity(Expression<Func<VCompanyUser, bool>> predicate)
 {
     using (UCDbContext db=new UCDbContext())
     {
         var model =db.VCompanyUsers.Where<VCompanyUser>(predicate);
         var sqlText = model.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return model.SingleOrDefault();
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:17,代码来源:VCompanyUserDaoImpl.cs


示例6: DeleteEntity

 /// <summary>
 /// 删除实体
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 public bool DeleteEntity(Expression<Func<TFunMyapp , bool>> predicate)
 {
     using (UCDbContext db=new UCDbContext())
     {
         TFunMyapp  entity = db.TFunMyapps.Where(predicate).First();
         int rows=db.TFunMyapps.Delete(entity);
          if (rows > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:20,代码来源:TFunMyappDaoImpl.cs


示例7: DeletesEntity

        /// <summary>
        /// 批量删除(实体集合)
        /// </summary>
        /// <param name="predicate">动态LINQ</param>
        public bool DeletesEntity(List<string> predicates)
        {
            using (UCDbContext db=new UCDbContext())
            {

                if (db.Connection.State != ConnectionState.Open)
                {
                    db.Connection.Open();
                }
                var tran = db.Connection.BeginTransaction();
                try
                {
                     foreach (var predicate in predicates)
                     {
                        var item = db.TFunMyapps.Where(predicate).FirstOrDefault();
                        if (null != item)
                         {
                            db.TFunMyapps.Delete(item);
                         }
                    }
                    tran.Commit();
                    LogHelper.Debug("批量删除成功!");
                    return true;
                }
              catch (Exception ex)
                {
                    tran.Rollback();
                    LogHelper.Error("批量删除异常:", ex);
                    return false;
                }
                finally
                {
                    if (db.Connection.State != ConnectionState.Closed)
                    {
                        db.Connection.Close();
                    }
                }
            }
        }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:43,代码来源:TFunMyappDaoImpl.cs


示例8: GetList

 /// <summary>
 /// 获取所有的数据
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 /// <returns>返回所有数据列表</returns>
 public List<TFunMyapp> GetList(Expression<Func<TFunMyapp, bool>> predicate)
 {
     using (UCDbContext db=new UCDbContext())
     {
      var models= db.TFunMyapps.Where<TFunMyapp>(predicate);
        var sqlText = models.GetProperty("SqlText");
      LogHelper.Debug(sqlText.ToString());
      return models.ToList();
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:15,代码来源:TFunMyappDaoImpl.cs


示例9: GetFields

 /// <summary>
 /// 根据条件查询某些字段(LINQ 动态查询)
 /// </summary>
 /// <param name="selector">要查询的字段(格式:new(ID,Name))</param>
 /// <param name="predicate">筛选条件(id=0)</param>
 /// <returns></returns>
 public IQueryable<Object> GetFields(string selector, string predicate, params object[] values)
 {
     using (UCDbContext db=new UCDbContext())
     {
         var model = db.TFunMyapps.Where(predicate,values).Select(selector);
         var sqlText = model.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return (IQueryable<object>) model;
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:16,代码来源:TFunMyappDaoImpl.cs


示例10: UpdateEntity

 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public bool UpdateEntity(TSysDepartment entity)
 {
     using (UCDbContext db=new UCDbContext())
     {
        int rows= db.TSysDepartments.Update(entity);
        if (rows > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:19,代码来源:TSysDepartmentDaoImpl.cs


示例11: GetEntityWithExp

        /// <summary>
        /// 返回单个实体(带扩展字段)
        /// </summary>
        /// <param name="selector">要查询的字段</param>
        /// <param name="expFields">存储扩展字段值的字段</param>
        /// <param name="expSelector">要查询的扩展字段里面的字段</param>
        /// <param name="predicate">查询条件</param>
        /// <param name="values">参数</param>
        /// <returns>Dictionary&lt;String, Object&gt;.</returns>
        public Dictionary<string, object> GetEntityWithExp(string selector, string expFields, string expSelector,
            string predicate,
            params object[] values)
        {
            using (UCDbContext db=new UCDbContext())
            {
                IQueryable<object> model=null;
                if (!String.IsNullOrEmpty(selector))
                {
                    model =
                        ((IQueryable<object>) db.TFunMyapps.Where(predicate, values).Select(selector, values));
                }
                else
                {
                    model = ((IQueryable<object>)db.TFunMyapps.Where(predicate, values));
                }

                object temp = model.FirstOrDefault();
                var sqlText = model.GetProperty("SqlText");
                 LogHelper.Debug("ELINQ Paging:<br/>" + sqlText.ToString());

                Dictionary<string, object> result = new Dictionary<string, object>();
                PropertyInfo[] propertyInfos = temp.GetType().GetProperties();
                foreach (var propertyInfo in propertyInfos)
                {
                    var name = propertyInfo.Name; //输入的selector中的字段名
                    var value = propertyInfo.GetValue(temp, null); //输入的selector中的字段值
                    if (name == expFields)
                    {
                        IDictionary<string, JToken> cusFields =
                            (JObject) JsonConvert.DeserializeObject(value.ToString());
                        //循环添加新字段
                        foreach (var field in cusFields)
                        {
                            //只输出已选择的扩展字段(不输出直接留空)
                            if (!String.IsNullOrEmpty(expSelector))
                            {
                                object[] exps = Utils.StringToObjectArray(expSelector, ',');
                                var fieldKey = NamingConversion.Default.PropertyName(field.Key);
                                var fieldvalue = field.Value;
                                if (exps.Contains(fieldKey)) //只查询选择的扩展字段
                                {
                                    result.Add(fieldKey, fieldvalue);
                                }
                            }
                        }
                    }
                    else
                    {
                        result.Add(name, value);
                    }
                }

                return result;
            }
        }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:65,代码来源:TFunMyappDaoImpl.cs


示例12: GetMaxId

 /// <summary>
 /// 获取最大Id(默认)
 /// </summary>
 /// <returns></returns>
 public int GetMaxId()
 {
     using (UCDbContext db=new UCDbContext())
        {
        var models = db.TFunMyapps.Max(temp => temp.Id);
        var sqlText = models.GetProperty("SqlText");
        LogHelper.Debug(sqlText.ToString());
        return models + 1;
        }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:14,代码来源:TFunMyappDaoImpl.cs


示例13: UpdateEntityStatus

        /// <summary>
        /// 使用LINQ批量更改TClientInfo状态 2014-09-05 14:58:50 By 唐有炜
        /// </summary>
        /// <param name="fields">要更新的字段(支持批量更新)</param>
        /// <param name="values">The values.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool UpdateEntityStatus(List<Field> fields, params  object[] values)
        {
            using (UCDbContext db=new UCDbContext())
            {
                if (db.Connection.State != ConnectionState.Open)
                {
                    db.Connection.Open();
                }
                var tran = db.Connection.BeginTransaction();
                try
                {
                    foreach (var field in fields)
                    {
                     var entity = db.TFunMyapps.Where(field.Predicate, values).FirstOrDefault();
                        var propertyInfos = entity.GetType().GetProperties();
                        foreach (var p in propertyInfos)
                        {
                            if (p.Name == field.Key)
                            {
                                p.SetValue(entity, field.Value, null); //给对应属性赋值
                            }
                        }
                        db.TFunMyapps.Update(entity);
                    }

                    tran.Commit();
                    LogHelper.Debug("TFunMyapp字段批量更新成功。");
                    return true;
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    LogHelper.Error("TFunMyapp字段批量更新异常:", ex);
                    return false;
                }
                finally
                {
                    if (db.Connection.State != ConnectionState.Closed)
                    {
                        db.Connection.Close();
                    }
                }
            }
        }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:50,代码来源:TFunMyappDaoImpl.cs


示例14: GetListWithExpByPage

        /// <summary>
        /// 查询分页(包括扩展字段) 2014-08-29 14:58:50 By 唐有炜
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页的数目</param>
        /// <param name="selector">要查询的字段</param>
        /// <param name="expFields">存储扩展字段值的字段</param>
        /// <param name="expSelector">要查询的扩展字段里面的字段</param>
        /// <param name="predicate">查询条件</param>
        /// <param name="ordering">排序</param>
        /// <param name="recordCount">记录结果数</param>
        /// <param name="values">参数</param>
        /// <returns>查询分页(包括扩展字段)</returns>
        public List<Dictionary<string, object>> GetListWithExpByPage(int pageIndex, int pageSize, string selector,
            string expFields, string expSelector,
            string predicate, string ordering,
            out int recordCount, params object[] values)
        {
            using (UCDbContext db=new UCDbContext())
            {
                //获取查询结果
                //加上扩展字段值
                var temps = db.TFunMyapps;
                recordCount = temps.Count();
                var prevCount = (pageIndex - 1)*pageSize;

                IQueryable<object> models = null;
                if (!String.IsNullOrEmpty(selector))
                {
                    models = (IQueryable<object>) (temps
                        .Skip(prevCount)
                        .Take(pageSize)
                        .Where(predicate, values)
                        .Select(selector, values)
                        .OrderBy(ordering));
                }
                else
                {
                    models = (IQueryable<object>)(temps
                        .Skip(prevCount)
                        .Take(pageSize)
                        .Where(predicate, values)
                        .OrderBy(ordering));
                }

                var sqlText = models.GetProperty("SqlText");
                LogHelper.Debug("ELINQ Dynamic Paging:<br/>" + sqlText.ToString());

                //转换为分页
                var pages = models.ToPagination(pageIndex, pageSize, recordCount);

                //组装输出
                List<Dictionary<string, object>> results = new List<Dictionary<string, object>>();
                foreach (var page in pages)
                {
                    Dictionary<string, object> result = new Dictionary<string, object>();
                    PropertyInfo[] propertyInfos = page.GetType().GetProperties();
                    foreach (var propertyInfo in propertyInfos)
                    {
                        var name = propertyInfo.Name; //输入的selector中的字段名
                        var value = propertyInfo.GetValue(page, null); //输入的selector中的字段值
                        if (name == expFields)
                        {
                            IDictionary<string, JToken> cusFields =
                                (JObject) JsonConvert.DeserializeObject(value.ToString());
                            //循环添加新字段
                            foreach (var field in cusFields)
                            {
                                //只输出已选择的扩展字段(不输出直接留空)
                                if (!String.IsNullOrEmpty(expSelector))
                                {
                                    object[] exps = Utils.StringToObjectArray(expSelector, ',');
                                    var fieldKey = NamingConversion.Default.PropertyName(field.Key);
                                    var fieldvalue = field.Value;
                                    if (exps.Contains(fieldKey)) //只查询选择的扩展字段
                                    {
                                        result.Add(fieldKey, fieldvalue);
                                    }
                                }
                            }
                        }
                        else
                        {
                            result.Add(name, value);
                        }
                    }
                    results.Add(result);
                }

                return results;
            }
        }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:92,代码来源:TFunMyappDaoImpl.cs


示例15: GetListByPage

        /// <summary>
        /// 查询分页(可以自定义添加属性,不包括扩展字段) 2014-10-15 14:58:50 By 唐有炜
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页的数目</param>
        /// <param name="selector">要查询的字段</param>
        /// <param name="predicate">查询条件</param>
        /// <param name="ordering">排序</param>
        /// <param name="recordCount">记录结果数</param>
        /// <param name="values">参数</param>
        /// <returns>查询分页(不包括扩展字段)</returns>
        public List<Dictionary<string, object>> GetListByPage(int pageIndex, int pageSize, string selector,string predicate, string ordering,
            out int recordCount, params object[] values)
        {
            using (UCDbContext db=new UCDbContext())
            {
                //获取查询结果
                //加上扩展字段值
                var temps = db.TFunMyapps;

                IQueryable<object> models = null;
                if (!String.IsNullOrEmpty(selector))
                {
                    models = (IQueryable<object>) (temps
                        .Where(predicate, values)
                        .Select(selector, values)
                        .OrderBy(ordering));
                }
                else
                {
                    models = (IQueryable<object>)(temps
                        .Where(predicate, values)
                        .OrderBy(ordering));
                }

                var sqlText = models.GetProperty("SqlText");
                LogHelper.Debug("ELINQ Dynamic Paging:<br/>" + sqlText.ToString());

                //计算总数
                recordCount = models.Count();

                //转换为分页
                var prevCount = (pageIndex - 1)*pageSize;
                models=models.Skip(prevCount).Take(pageSize);
                var pages = models.ToPagination(pageIndex, pageSize, recordCount);

                //组装输出
                List<Dictionary<string, object>> results = new List<Dictionary<string, object>>();
                foreach (var page in pages)
                {
                    Dictionary<string, object> result = new Dictionary<string, object>();
                    PropertyInfo[] propertyInfos = page.GetType().GetProperties();
                    foreach (var propertyInfo in propertyInfos)
                    {
                        var name = propertyInfo.Name; //输入的selector中的字段名
                        var value = propertyInfo.GetValue(page, null); //输入的selector中的字段值
                        result.Add(name, value);

                    }
                    results.Add(result);
                }

                return results;
            }
        }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:65,代码来源:TFunMyappDaoImpl.cs


示例16: GetViewList

 /// <summary>
 /// 获取所有的数据
 /// </summary>
 /// <returns>返回所有数据列表</returns>
 public List<VCustomerContact> GetViewList()
 {
     using (UCDbContext db=new UCDbContext())
     {
      var models= db.VCustomerContacts;
       var sqlText = models.GetProperty("SqlText");
      LogHelper.Debug(sqlText.ToString());
      return models.ToList();
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:14,代码来源:VCustomerContactDaoImpl.cs


示例17: GetViewListBySql

 //以下是原生Sql方法==============================================================
 //===========================================================================
 /// <summary>
 /// 用SQL语句查询
 /// </summary>
 /// <param name="sql">sql语句</param>
 /// <param name="namedParameters">sql参数</param>
 /// <returns>集合</returns>
 public DataTable GetViewListBySql(string sql, dynamic namedParameters)
 {
     using (UCDbContext db=new UCDbContext())
     {
        return db.DbHelper.ExecuteDataTable(sql,namedParameters).ToList<VCompanyUser>();
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:15,代码来源:VCompanyUserDaoImpl.cs


示例18: GetViewFields

 /// <summary>
 /// 根据条件查询某些字段(LINQ 动态查询)
 /// </summary>
 /// <param name="selector">要查询的字段(格式:new(ID,Name))</param>
 /// <param name="predicate">筛选条件(id=0)</param>
 /// <returns></returns>
 public IQueryable<Object> GetViewFields(string selector, string predicate)
 {
     using (UCDbContext db=new UCDbContext())
     {
         var model = db.VCompanyUsers.Where(predicate).Select(selector);
         var sqlText = model.GetProperty("SqlText");
         LogHelper.Debug(sqlText.ToString());
         return (IQueryable<object>) model;
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:16,代码来源:VCompanyUserDaoImpl.cs


示例19: GetListBySql

 //以下是原生Sql方法==============================================================
 //===========================================================================
 /// <summary>
 /// 用SQL语句查询
 /// </summary>
 /// <param name="sql">sql语句</param>
 /// <param name="namedParameters">sql参数</param>
 /// <returns>集合</returns>
 public DataTable GetListBySql(string sql, dynamic namedParameters)
 {
     using (UCDbContext db=new UCDbContext())
     {
        return db.DbHelper.ExecuteDataTable(sql,namedParameters).ToList<TFunMyapp>();
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:15,代码来源:TFunMyappDaoImpl.cs


示例20: ExistsEntity

 /// <summary>
 /// 是否存在该记录
 /// </summary>
 /// <returns></returns>
 public bool ExistsEntity(Expression<Func<TFunMyapp , bool>> predicate)
 {
     using (UCDbContext db=new UCDbContext())
     {
        bool status= db.TFunMyapps.Any(predicate);
        return status;
     }
 }
开发者ID:khaliyo,项目名称:UCsoft,代码行数:12,代码来源:TFunMyappDaoImpl.cs



注:本文中的UCsoft.Data.UCDbContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Components.Database类代码示例发布时间:2022-05-26
下一篇:
C# Twitterizer.OptionalProperties类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap