⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expressionexpand.cs

📁 smark.data是基于C#开发的轻量级数据访问组件。 提供以下功能封: 1)提供了跨数据库类型操作能力 2)基于程线存储的数据访问上下文对象
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using Smark.Data.Mappings;
namespace Smark.Data
{
    public  partial class Expression
    {

        public IList<T> List<T>() where T : Mappings.DataObject, new()
        {
            return List<T>((Region)null);
        }
        public IList<T> List<T>(Region region) where T : Mappings.DataObject, new()
        {
            return List<T>(region, null);
        }
        public IList<T> List<T>(Region region,string orderby) where T : Mappings.DataObject,new()
        {
            ObjectMapper om = ObjectMapper.GetOM(typeof(T));
            using (IConnectinContext cc = om.Connection.GetContext())
            {
                return List<T>(cc, region, orderby);
            }
        }
        public IList<T> List<T>(IConnectinContext cc) where T : Mappings.DataObject, new()
        {
            return List<T>(cc, null, null);
        }
        public IList<T> List<T>(IConnectinContext cc,Region region) where T : Mappings.DataObject, new()
        {
            return List<T>(cc, region, null);
        }
        public IList<T> List<T>(IConnectinContext cc, Region region, string orderby) where T : Mappings.DataObject,new()
        {
            ObjectMapper om = ObjectMapper.GetOM(typeof(T));
            return EntityBase.ExOnList<T>(cc, om.Select, this, region, orderby, om.GroupBy);
        }
        public T ListFirst<T>() where T : Mappings.DataObject, new()
        {
            return ListFirst<T>((string)null);
        }
        public T ListFirst<T>(IConnectinContext cc) where T : Mappings.DataObject, new()
        {
            return ListFirst<T>(cc, null);
        }
        public T ListFirst<T>(string orderby) where T : Mappings.DataObject, new()
        {

            ObjectMapper om = ObjectMapper.GetOM(typeof(T));
            using (IConnectinContext cc = om.Connection.GetContext())
            {
                return ListFirst<T>(cc, orderby);
            }

        }
        public T ListFirst<T>(IConnectinContext cc, string orderby) where T:Mappings.DataObject,new()
        {
            ObjectMapper om = ObjectMapper.GetOM(typeof(T));

            return EntityBase.ExOnListFirst<T>(cc, om.Select, this, orderby, om.GroupBy);
        }

        public void Delete<T>()
        {
            ObjectMapper om = ObjectMapper.GetOM(typeof(T));
            using (IConnectinContext cc = om.Connection.GetContext())
            {
                Delete<T>(cc);
            }
        }
        public void Delete<T>(IConnectinContext cc)
        {
            ObjectMapper om = ObjectMapper.GetOM(typeof(T));
            EntityBase.ExOnDelete(cc, om.Table, this);
        }
        public void Edit<T>(params Field[] fields)
        {
            ObjectMapper om = ObjectMapper.GetOM(typeof(T));
            using (IConnectinContext cc = om.Connection.GetContext())
            {
                Edit<T>(cc);
            }
        }
        public void Edit<T>(IConnectinContext cc, params Field[] fields)
        {
            if (fields == null || fields.Length == 0)
                return;
            ObjectMapper om = ObjectMapper.GetOM(typeof(T));
            Update update = new Update(om.Table);
            update.Where = this;
            foreach (Field f in fields)
            {
                update.AddField(f.Name, f.Value);
            }
            update.Execute(cc);
            
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -