File: EntityDesignerDataSourceView.cs

package info (click to toggle)
mono 4.6.2.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 778,148 kB
  • ctags: 914,052
  • sloc: cs: 5,779,509; xml: 2,773,713; ansic: 432,645; sh: 14,749; makefile: 12,361; perl: 2,488; python: 1,434; cpp: 849; asm: 531; sql: 95; sed: 16; php: 1
file content (102 lines) | stat: -rw-r--r-- 2,879 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//------------------------------------------------------------------------------
// <copyright file="EntityDesignerDataSourceView.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//
// @owner       [....]
// @backupOwner [....]
//------------------------------------------------------------------------------
using System.Collections;
using System.Data;
using System.Web.UI.Design;

namespace System.Web.UI.Design.WebControls
{
    public class EntityDesignerDataSourceView : DesignerDataSourceView
    {
        private EntityDataSourceDesignerHelper _helper;

        public EntityDesignerDataSourceView(EntityDataSourceDesigner owner)
            : base(owner, EntityDataSourceDesignerHelper.DefaultViewName)
        {
            _helper = owner.Helper;
        }

        public override bool CanDelete
        {
            get
            {
                return CanModify && _helper.EnableDelete;
            }
        }

        public override bool CanInsert
        {
            get
            {
                return CanModify && _helper.EnableInsert;
            }
        }

        internal bool CanModify
        {
            get
            {
                return !String.IsNullOrEmpty(_helper.EntitySetName) &&
                    String.IsNullOrEmpty(_helper.Select) && 
                    String.IsNullOrEmpty(_helper.CommandText) &&
                    String.IsNullOrEmpty(_helper.GroupBy);
            }
        }

        public override bool CanPage
        {
            get
            {
                return _helper.CanPage;
            }
        }

        public override bool CanSort
        {
            get
            {
                return _helper.CanSort;
            }
        }

        public override bool CanUpdate
        {
            get
            {
                return CanModify && _helper.EnableUpdate;
            }
        }

        public override IDataSourceViewSchema Schema
        {
            get
            {
                DataTable schemaTable = _helper.LoadSchema();
                if (schemaTable == null)
                {
                    return null;
                }
                return new DataSetViewSchema(schemaTable);
            }
        }

        public override IEnumerable GetDesignTimeData(int minimumRows, out bool isSampleData)
        {
            DataTable schemaTable = _helper.LoadSchema();
            if (schemaTable != null)
            {
                isSampleData = true;
                return DesignTimeData.GetDesignTimeDataSource(DesignTimeData.CreateSampleDataTable(new DataView(schemaTable), true), minimumRows);
            }

            // Couldn't find design-time schema, use base implementation
            return base.GetDesignTimeData(minimumRows, out isSampleData);
        }
    }
}