zoukankan      html  css  js  c++  java
  • 对强类型DataSet功能进行扩展

    对于Visual Studio产生的DataSet我们是不可以直接修改其代码的.我们可以通过.NET 2.0的一个新功能.不修改原代码.对其功能(partial)进行扩展

    假设我原来DataSet类为SchoolDS

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace SchoolProject.BLL.Entities
    {
        
    public partial class SchoolDS : System.Data.DataSet
        
    {
            
    //公开各Relation
            public string FK_Courses_Classes()
            
    {
                
    return this.relationFK_Courses_Classes.RelationName;
            }

            
    public string FK_Courses_Subjects()
            
    {
                
    return this.relationFK_Courses_Subjects.RelationName;
            }

            
    public string FK_Scores_Courses()
            
    {
                
    return this.relationFK_Scores_Courses.RelationName;
            }

            
    public string FK_Scores_Students()
            
    {
                
    return this.relationFK_Scores_Students.RelationName;
            }

            
    public string FK_Students_Classes()
            
    {
                
    return this.relationFK_Students_Classes.RelationName;
            }


            
    //ClassesRow是此DataSet的一个内部类,可以使用类视图看到
            
    //重写内部类的ToString()方法
            public partial class ClassesRow : System.Data.DataRow
            
    {
                
    public override string ToString()
                
    {
                    
    return this.ClassName;
                }

            }

            
    public partial class SubjectsRow : System.Data.DataRow
            
    {
                
    public override string ToString()
                
    {
                    
    return this.SubjectName;
                }

            }

        }

    }


  • 相关阅读:
    显示屏分辨率自动调整例子
    该内存不能read 或written数值 叙述
    DELPHI之关于String的内存分配(引)
    Delphi关于记录文件的操作转
    用句柄操作下拉框
    SendMessage参数
    c#通过SendMessage发送消息
    Delphi内存专题 (引)
    Delphi7 中使用ODAC存取图片
    打印机状态测试
  • 原文地址:https://www.cnblogs.com/tonyepaper/p/1044994.html
Copyright © 2011-2022 走看看