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;
                }

            }

        }

    }


  • 相关阅读:
    为Mac Terminal设置代理
    Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo
    vue.js环境搭建
    nodejs实现的简单接口
    Runtime
    iOS -- 神战
    前端视频
    iOS-- 重要的链接
    Oracle 11g R2安装手册(图文教程)For Windows
    undo_retention:确定最优的撤销保留时间
  • 原文地址:https://www.cnblogs.com/tonyepaper/p/1044994.html
Copyright © 2011-2022 走看看