访问|数据具体的Data Access Logic实现技术,作者感觉已没有必要多加讨
论,相信只要是有过ADO.NET开发经验的同志都比较清楚应该怎
么做,网上的资料也浩如烟海,非常齐全!
 
   在此,就以作者自己的一段Data Access Logic代码来结束关于它的讨论:
   
   代码11:使用Data Access Logic进行Remoting调用 – 1,基本操作
class CustomerDal_ORM : MyDal
{
protected internal MyCustomer GetAllCustomers()
    {
       MyCustomer cust = null;
       
       // 获取Distributed Process类型
       string typeDist = GetDistributionType();
       switch (typeDist)
       {
           case DistributionType.REMOTING :
           {
              // 通过Cache Management访问数据,第2参数是个delegate,
              //   一旦Cache失效,就直接通过该delegate刷新数据
              ArrayList al = CacheManager.Current.GetCache(
GetCacheParam(), GetAllCustomers_Remoting_delegate);
              ...  // 对Remoting返回的数据进行处理
              break;
           }
 
           default :
              throw new Exception(
"Unsupported DistributionType: " + 
typeDist + "!");
           }
           
           return cust;
       }
    }
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
上面的是基本访问代码,由于使用了Cache Management,所以
我们还需要一段真正可以访问数据的代码,一旦Cache失效,就可
以通过它来再次获得数据并刷新缓存!
   需要特别注意的是:上面的代码使用了C# 2.0中的Anonymous 
Delegate功能,如果在Visual Studio .NET 2003种进行编译,必须将
GetAllCustomers_Remoting_delegate参数修改为如下方式:
new GetArrayList(GetAllCustomers_Remoting_delegate)
(这里的GetArrayList就是真正定义的delegate类型)
 
下一段:http://www.csdn.net/develop/Read_Article.asp?id=27557 
                   
实战 .Net 数据访问层 - 13
                    80酷酷网    80kuku.com 
       
  
 
 
  
