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

            }

        }

    }


  • 相关阅读:
    html优化
    HTML练习(网页计算器)
    hdu--4574 Bombs(dfs)
    Robots at Warehouse(搜索+vector的使用)
    poj 2111 Millenium Leapcow(记忆化搜索)
    Codeforces Round #408 (Div. 2) C. Bank Hacking(暴力啊!暴力)
    Gym
    Gym
    浙江省赛--D
    浙江省赛--C
  • 原文地址:https://www.cnblogs.com/tonyepaper/p/1044994.html
Copyright © 2011-2022 走看看