替换返回值 - 从数据门户到数据表

本文关键字:数据表 数据 返回值 替换 | 更新日期: 2023-09-27 18:33:34

 public static CustomizeCourseCompletionWithModuleList GetCustomizeCourseCompletionWithModuleList()
{
    var cmd = new StoredProcedure
    {
        CommandText = "CustomizeCourseCompletionWithModuleSelectById",
        CommandType = System.Data.CommandType.StoredProcedure
    };
    cmd.Parameters.Add("@ID", DBNull.Value);
    return DataPortal.Fetch<CustomizeCourseCompletionWithModuleList>(cmd);
}
最后,我想返回数据表,而不是返回数据门户,我应该怎么做?

自定义课程完成与模块列表类:

public class CustomizeCourseCompletionWithModuleList : BusinessListBase<CustomizeCourseCompletionWithModule>
{
    #region  Business Methods
    public CustomizeCourseCompletionWithModule GetItem(int childId)
    {
        return this.FirstOrDefault(child => child.Id == childId);
    }
    public override void Remove(int childId)
    {
        foreach (var child in this.Where(child => child.Id == childId))
        {
            RemoveChild(child);
            break;
        }
    }
    public bool Contains(int childId)
    {
        return this.Any(child => child.Id == childId);
    }
    public bool ContainsDeleted(int childId)
    {
        return DeletedList.Any(child => child.Id == childId && child.IsDeleted);
    }
    #endregion

存储过程 :

public class StoredProcedure : ICloneable
{
    private Parameters _parameters = new Parameters();
    private string _procName;
    public StoredProcedure(string name)
    {
        _procName = name;
        CommandType = System.Data.CommandType.StoredProcedure;
    }
    public StoredProcedure()
    {
        CommandType = System.Data.CommandType.StoredProcedure;
    }
    [DataMember]
    public String CommandText
    {
        get { return _procName; }
        set { _procName = value; }
    }
    [DataMember]
    public System.Data.CommandType CommandType { get; set; }
    [DataMember]
    public string Name
    {
        get { return _procName; }
        set { _procName = value; }
    }
    [DataMember]
    public Parameters Parameters
    {
        get { return _parameters; }
        set { _parameters = value; }
    }

    #region ICloneable Members
    object ICloneable.Clone()
    {
        return GetClone();
    }
    [EditorBrowsable(EditorBrowsableState.Advanced)]
    protected virtual object GetClone()
    {
        return ObjectCloner.Clone(this);
    }
    #endregion
}

如果您需要任何其他信息,请询问,以便您给我一个正确的答案。提前谢谢。

替换返回值 - 从数据门户到数据表

我不确定这是否有帮助,但我做了一些挖掘,我遇到了这篇文章,其中讨论了使用 CLSA 的 ObjectAdapter 将列表转换为数据集。Csla.Data.ObjectAdapter

//Get the a musicians BusinessBaseList
MusiciansList musicians = MusiciansList.GetList();
//Use the ObjectAdapter to transform the list into
//a DataSet
ObjectAdapter adapter = new ObjectAdapter();
DataSet ds = new DataSet();
adapter.Fill(ds, musicians);
//Bind the DataSet to the musician’s 
//DropDownList
ddMusicians.DataSource = ds.Tables[0];
ddMusicians.DataTextField = "LastName";
ddMusicians.DataValueField = "Id";
ddMusicians.DataBind();