????1????????????????????????????
??????????????????IDAL????ж???????IOu_UserInfoDAL????????????partial????????????????Щ?????????????????????ExtensionIDAL?н??й??????????????????????????????
????using Model;
????namespace IDAL
????{
????public partial interface IOu_UserInfoDAL
????{
????Ou_UserInfo GetUserInfoByName(string loginName);
????}
????}
????2??DAL????У?????????ExtensionDAL????????????????????Ou_UserInfoDAL
????using IDAL;
????using Model;
????namespace DAL
????{
????public partial class Ou_UserInfoDAL : IOu_UserInfoDAL
????{
????public Ou_UserInfo GetUserInfoByName(string loginName)
????{
????return base.GetListBy(x => x.uLoginName == loginName).FirstOrDefault();
????}
????}
????}
????3??IBLL???????????ExtensionIBLL??????????????IOu_UserInfoBLL???
????using Model;
????namespace IBLL
????{
????public partial interface IOu_UserInfoBLL
????{
????Ou_UserInfo Login(string strName?? string strPwd);
????}
????}
????BLL?????????????ExtensionBLL??????????????Ou_UserInfoBLL??
????using Model;
????using IBLL;
????namespace BLL
????{
????public partial class Ou_UserInfoBLL : IOu_UserInfoBLL
????{
????/// <summary>
????/// ???
????/// </summary>
????/// <param name="strName"></param>
????/// <param name="strPwd"></param>
????/// <returns></returns>
????public Ou_UserInfo Login(string strName?? string strPwd)
????{
????//1.?????????? ???????????
????Ou_UserInfo usr = base.GetListBy(u => u.uLoginName == strName).FirstOrDefault();
????//2.?ж?????????
????return null;
????}
????}
????}
????4??????spring.net???????ο???17??ASP.NET MVC????????——Spring.net????
????????????????spring.net????????Spring.Core.dll ??Common.Logging.dll????????????Web???????????Lib???????????????????dll??
????DI????У??????????dll???????????????SpringHelper
????using Spring.Context;
????using Spring.Context.Support;
????namespace DI
????{
????public static class SpringHelper
????{
????#region 1.0 Spring?????????? -IApplicationContext SpringContext
????/// <summary>
????/// Spring??????????
????/// </summary>
????private static IApplicationContext SpringContext
????{
????get
????{
????return ContextRegistry.GetContext();
????}
????}
????#endregion
????#region 2.0 ?????????? ????? ???? +T GetObject<T>(string objName) where T : class
????/// <summary>
????/// ?????????? ????? ????
????/// </summary>
????/// <typeparam name="T"></typeparam>
????/// <param name="objName"></param>
????/// <returns></returns>
????public static T GetObject<T>(string objName) where T : class
????{
????return (T)SpringContext.GetObject(objName);
????}
????#endregion
????}
????5?????Web????е?Web.config????????Spring????
????<!-- Spring ?????? -->
????<sectionGroup name="spring">
????<section name="context" type="Spring.Context.Support.WebContextHandler?? Spring.Web"/>
????<!-- ????? web.config ?ж?????? -->
????<section name="objects" type="Spring.Context.Support.DefaultSectionHandler?? Spring.Core" />
????</sectionGroup>
????</configSections>
????<spring>
????<context>
????<resource uri="~/Config/objects.xml"/>
????</context>
????</spring>
????Web????д????????? Config ??????У??????????????????
????<?xml version="1.0" encoding="utf-8" ?>
????<objects xmlns="http://www.springframework.net">
????<object id="Ou_UserInfo" type="BLL.Ou_UserInfo??BLL" singleton="false"></object>
????<object id="BLLSession" type="BLL.BLLSession??BLL" singleton="false"></object>
????<object id="DBSessFactory" type="DAL.DBSessionFactory??DAL"></object>
????</objects>
???????BaseBLL.cs
????#region ?????? ???? + IDBSession DBSession
????/// <summary>
????/// ?????? ????
????/// </summary>
????public IDAL.IDBSession DBSession
????{
????get
????{
????if (iDbSession == null)
????{
????////1.??????????
????//string strFactoryDLL = Common.ConfigurationHelper.AppSetting("DBSessionFatoryDLL");
????//string strFactoryType = Common.ConfigurationHelper.AppSetting("DBSessionFatory");
????////2.1????????? DBSessionFactory ????????
????//Assembly dalDLL = Assembly.LoadFrom(strFactoryDLL);
????//Type typeDBSessionFatory = dalDLL.GetType(strFactoryType);
????//IDAL.IDBSessionFactory sessionFactory = Activator.CreateInstance(typeDBSessionFatory) as IDAL.IDBSessionFactory;
????//2.??????????????? ??? DI?????Spring.Net ???? DBSessionFactory ????????
????IDAL.IDBSessionFactory sessionFactory = DI.SpringHelper.GetObject<IDAL.IDBSessionFactory>("DBSessFactory");
????//3.??? ???? ???? DBSession????
????iDbSession = sessionFactory.GetDBSession();
????}
????return iDbSession;
????}
????}
????#endregion