/// <summary> /// 插入一个实体 /// </summary> /// <param name="entity">要插入的实体</param> /// <param name="fillIdentity">是否填充主键</param> /// <returns></returns> public static object Insert(EntityBase entity, bool fillIdentity) { Type type = CH.GetRealType(entity); string name = type.FullName; object bo = DataAccessLoader.GetBoInstance(name); FastInvokeHandler inv = FastValueGetSet.GetCustomerMethodInfo(bo.GetType(), "Insert", new Type[] { type, typeof(bool) }); return(inv(bo, new object[] { entity, fillIdentity })); }
/// <summary> /// 获取唯一 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="lstScope">条件</param> /// <returns></returns> public static T GetUnique <T>(ScopeList lstScope) where T : EntityBase, new() { string name = typeof(T).FullName; BusinessModelBase <T> bo = DataAccessLoader.GetBoInstance(name) as BusinessModelBase <T>; if (bo == null) { throw new MissingMemberException("找不到:" + name + " 对应的业务类"); } return(bo.GetUnique(lstScope)); }
/// <summary> /// 根据ID获取实体 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="id">id</param> /// <returns></returns> public static T GetById <T>(object id) where T : EntityBase, new() { string name = typeof(T).FullName; BusinessModelBase <T> bo = DataAccessLoader.GetBoInstance(name) as BusinessModelBase <T>; if (bo == null) { throw new MissingMemberException("找不到:" + name + " 对应的业务类"); } return(bo.GetEntityById(id)); }
/// <summary> /// 获取唯一 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="condition">条件</param> /// <returns></returns> public static T GetUnique <T>(BQLCondition condition) where T : EntityBase, new() { string name = typeof(T).FullName; BusinessModelBase <T> bo = DataAccessLoader.GetBoInstance(name) as BusinessModelBase <T>; if (bo == null) { throw new MissingMemberException("找不到:" + name + " 对应的业务类"); } ScopeList lstScope = new ScopeList(); if (!CommonMethods.IsNull(condition)) { lstScope.Add(condition); } return(bo.GetUnique(lstScope)); }