zoukankan      html  css  js  c++  java
  • 框架草稿

    1.
    
    using System;

    13606924440
    15860721564
    18359241319

    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using Framework;
    using Contract.Domain;
    using Framework.Domain;
    using System.Xml;
    using BaseService;
    using IBasDaoService;
    
    namespace BaseService
    {
    public interface IBaseService<T> where T : Framework.Domain.Entity, new()
    {
    IBasDaoService.IBasDao<T> CurrentDao { get; set; }
    T FindById(object Id);
    }
    public abstract class BaseService<T>:IBaseService<T> where T : Entity,new()
    {
    
    }
    3.
    using Contract.Domain;
    using Framework.IService;
    using NHibernate;
    using NHibernate.Linq;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace IBasDaoService
    {
    public interface IBasDao<T> where T : Framework.Domain.Entity, new()
    {
    
    T FindById(object Id);
    
    
    }
    public class BasDao<T> : IBasDao<T> where T : Framework.Domain.Entity, new()
    {
    private Spring.Context.IApplicationContext _ctx;
    protected Spring.Context.IApplicationContext ctx
    {
    get
    {
    if (_ctx == null)
    _ctx = Spring.Context.Support.ContextRegistry.GetContext();
    return _ctx;
    }
    }
    private Framework.IService.ICommonService _dao;
    public Framework.IService.ICommonService Dao
    {
    get
    {
    if (_dao == null)
    {
    _dao = (Framework.IService.ICommonService)ctx["CommonService"];
    }
    return _dao;
    }
    set
    {
    _dao = value;
    }
    }
    private static ISession _dbContext;
    protected static ISession DbContext
    {
    get
    {
    
    _dbContext = ((ICommonService)Spring.Context.Support.ContextRegistry.GetContext()["CommonService"]).GetSession();
    return _dbContext;
    }
    }
    public virtual T FindById(object Id)
    {
    
    return DbContext.Query<T>().AsEnumerable().Where(x => x.Id == Id.ToString()).FirstOrDefault();
    }
    }
    
    public class SysDictTypeDao : BasDao<SysDictType>, IBasDao<SysDictType>
    {
    
    public override SysDictType FindById(object Id)
    {
    return (SysDictType)base.FindById(Id);
    }
    }
    
    }
    
    
    4.
    
    <!--泛型dao的注入-->
    <object id="CurrentSysDictTypeDao" type="IBasDaoService.SysDictTypeDao, IBasDaoService">
    </object>
    <object id="SysDictTypeService" type="Bll.SysDictTypeService, HRABLL">
    <property name="Dao" ref="CommonService"/>
    <property name="CurrentDao" ref="CurrentSysDictTypeDao"/>
    </object>
  • 相关阅读:
    The Python Standard Library
    Python 中的round函数
    Python文件类型
    Python中import的用法
    Python Symbols 各种符号
    python 一行写多个语句
    免费SSL证书(https网站)申请,便宜SSL https证书申请
    元宇宙游戏Axie龙头axs分析
    OLE DB provider "SQLNCLI10" for linked server "x.x.x.x" returned message "No transaction is active.".
    The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "xxx.xxx.xxx.xxx" was unable to begin a distributed transaction.
  • 原文地址:https://www.cnblogs.com/kexb/p/5873682.html
Copyright © 2011-2022 走看看