Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Web.Entity.Design / System / Data / WebControls / Design / EntityDesignerDataSourceView.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="EntityDesignerDataSourceView.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       [....]
7 // @backupOwner [....]
8 //------------------------------------------------------------------------------
9 using System.Collections;
10 using System.Data;
11 using System.Web.UI.Design;
12
13 namespace System.Web.UI.Design.WebControls
14 {
15     public class EntityDesignerDataSourceView : DesignerDataSourceView
16     {
17         private EntityDataSourceDesignerHelper _helper;
18
19         public EntityDesignerDataSourceView(EntityDataSourceDesigner owner)
20             : base(owner, EntityDataSourceDesignerHelper.DefaultViewName)
21         {
22             _helper = owner.Helper;
23         }
24
25         public override bool CanDelete
26         {
27             get
28             {
29                 return CanModify && _helper.EnableDelete;
30             }
31         }
32
33         public override bool CanInsert
34         {
35             get
36             {
37                 return CanModify && _helper.EnableInsert;
38             }
39         }
40
41         internal bool CanModify
42         {
43             get
44             {
45                 return !String.IsNullOrEmpty(_helper.EntitySetName) &&
46                     String.IsNullOrEmpty(_helper.Select) && 
47                     String.IsNullOrEmpty(_helper.CommandText) &&
48                     String.IsNullOrEmpty(_helper.GroupBy);
49             }
50         }
51
52         public override bool CanPage
53         {
54             get
55             {
56                 return _helper.CanPage;
57             }
58         }
59
60         public override bool CanSort
61         {
62             get
63             {
64                 return _helper.CanSort;
65             }
66         }
67
68         public override bool CanUpdate
69         {
70             get
71             {
72                 return CanModify && _helper.EnableUpdate;
73             }
74         }
75
76         public override IDataSourceViewSchema Schema
77         {
78             get
79             {
80                 DataTable schemaTable = _helper.LoadSchema();
81                 if (schemaTable == null)
82                 {
83                     return null;
84                 }
85                 return new DataSetViewSchema(schemaTable);
86             }
87         }
88
89         public override IEnumerable GetDesignTimeData(int minimumRows, out bool isSampleData)
90         {
91             DataTable schemaTable = _helper.LoadSchema();
92             if (schemaTable != null)
93             {
94                 isSampleData = true;
95                 return DesignTimeData.GetDesignTimeDataSource(DesignTimeData.CreateSampleDataTable(new DataView(schemaTable), true), minimumRows);
96             }
97
98             // Couldn't find design-time schema, use base implementation
99             return base.GetDesignTimeData(minimumRows, out isSampleData);
100         }
101     }
102 }