标题:设计契约违背,要求在事务中进行,但当前操作未在事务中!
只看楼主
yelang7
Rank: 1
等 级:新手上路
威 望:1
帖 子:265
专家分:0
注 册:2006-11-3
 问题点数:0 回复次数:0 
设计契约违背,要求在事务中进行,但当前操作未在事务中!

大家好,我在调试一个程序是,报了一个这样的错:"Dbc(Design By Contract)设计契约违背。(DataAccessor要求在事务中进行,但当前操作未在事务中!)",请版主给帮忙看看的.下面是源码:
using System;
using System.Collections.Generic;
using System.Text;
using Eai.Data;

namespace OA.Biz.Domain
{
public class AbstractManager<T>
where T : new()
{
public IDataAccessor DataAccessor
{
get
{
return DataAccessContext.Current.GetDataAccessor();
}
}
public List<T> GetList()
{
System.Collections.IList oldList = DataAccessor.Query("From " + typeof(T));
List<T> list = ToGenericList(oldList);
return list;

}

public static List<T> ToGenericList(System.Collections.IList oldList)
{
List<T> list = new List<T>();
foreach (T t in oldList)
{
list.Add(t);
}
return list;
}
public virtual void Create(T t)
{
DataAccessor.Create(t);
}
public virtual void Delete(T t)
{
DataAccessor.Delete(t);
}
public virtual void Delete(Guid id)
{
Delete(Get(id));
}
public virtual void Update(T t)
{
DataAccessor.Update(t);
}

public virtual T Get(string id)
{
return Get(new Guid(id));
}

public virtual T Get(Guid id)
{
return (T)DataAccessor.Get(typeof(T), id); //错误处
}

public virtual T Get(Guid? id)
{
if (id == null) return new T();
return Get((Guid)id);
}
}
}

搜索更多相关主题的帖子: public return Design where 
2007-07-16 15:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-155774-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.071243 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved