Clover.NET coverage report - Coverage for s2container.net

Coverage timestamp: 2006年5月30日 11:21:29

File Stats: LOC: 76   Methods: 4
NCLOC: 53 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Framework.Util\DataTableUtil.cs 100.0% 100.0% 75.0% 96.4%
coverage coverage
1   #region Copyright
2   /*
3   * Copyright 2005 the Seasar Foundation and the Others.
4   *
5   * Licensed under the Apache License, Version 2.0 (the "License");
6   * you may not use this file except in compliance with the License.
7   * You may obtain a copy of the License at
8   *
9   * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14   * either express or implied. See the License for the specific language
15   * governing permissions and limitations under the License.
16   */
17   #endregion
18  
19   using System;
20   using System.Collections;
21   using System.Data;
22   using Seasar.Extension.ADO;
23  
24   namespace Seasar.Framework.Util
25   {
26   public sealed class DataTableUtil
27   {
28 0 private DataTableUtil()
29   {
30   }
31  
32 34 public static bool IsPrimaryKey(DataTable table, DataColumn column)
33   {
34 34 return Array.IndexOf(table.PrimaryKey, column) != -1;
35   }
36  
37 7 public static void SetupMetaData(IDatabaseMetaData dbMetaData, DataTable table)
38   {
39 7 IList primaryKeySet = dbMetaData.GetPrimaryKeySet(table.TableName);
40 7 IList columnSet = dbMetaData.GetColumnSet(table.TableName);
41 7 ArrayList primaryKeyList = new ArrayList();
42 7 foreach (DataColumn column in table.Columns)
43   {
44 17 if (primaryKeySet.Contains(column.ColumnName))
45   {
46 7 primaryKeyList.Add(column);
47   }
48  
49 17 if (columnSet.Contains(column.ColumnName))
50   {
51 14 column.ReadOnly = false;
52   }
53   else
54   {
55 3 column.ReadOnly = true;
56   }
57   }
58  
59 7 table.BeginLoadData();
60 7 table.PrimaryKey = (DataColumn[]) primaryKeyList.ToArray(typeof(DataColumn));
61 7 table.EndLoadData();
62   }
63  
64 26 public static DataColumn GetColumn(DataTable table, string columnName)
65   {
66 26 DataColumn column = table.Columns[columnName];
67 26 if (column == null)
68   {
69 2 string name = columnName.Replace("_", "");
70 2 column = table.Columns[name];
71   }
72 26 return column;
73   }
74   }
75   }
76