1 //---------------------------------------------------------------------
2 // <copyright file="TableDetailsRow.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9 using System.Collections.Generic;
11 using System.Data.Entity.Design.Common;
12 using System.Globalization;
15 namespace System.Data.Entity.Design.SsdlGenerator
18 /// Strongly typed DataTable for TableDetails
20 internal sealed class TableDetailsRow : System.Data.DataRow
23 private TableDetailsCollection _tableTableDetails;
25 [System.Diagnostics.DebuggerNonUserCodeAttribute()]
26 internal TableDetailsRow(System.Data.DataRowBuilder rb)
30 this._tableTableDetails = ((TableDetailsCollection)(base.Table));
34 /// Gets a strongly typed table
36 public new TableDetailsCollection Table
40 return _tableTableDetails;
45 /// Gets the Catalog column value
53 return ((string)(this[this._tableTableDetails.CatalogColumn]));
55 catch (System.InvalidCastException e)
57 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.CatalogColumn.ColumnName, _tableTableDetails.TableName, e);
62 this[this._tableTableDetails.CatalogColumn] = value;
67 /// Gets the Schema column value
75 return ((string)(this[this._tableTableDetails.SchemaColumn]));
77 catch (System.InvalidCastException e)
79 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.SchemaColumn.ColumnName, _tableTableDetails.TableName, e);
84 this[this._tableTableDetails.SchemaColumn] = value;
89 /// Gets the TableName column value
91 public string TableName
97 return ((string)(this[this._tableTableDetails.TableNameColumn]));
99 catch (System.InvalidCastException e)
101 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.TableNameColumn.ColumnName, _tableTableDetails.TableName, e);
106 this[this._tableTableDetails.TableNameColumn] = value;
111 /// Gets the ColumnName column value
113 public string ColumnName
119 return ((string)(this[this._tableTableDetails.ColumnNameColumn]));
121 catch (System.InvalidCastException e)
123 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.ColumnNameColumn.ColumnName, _tableTableDetails.TableName, e);
128 this[this._tableTableDetails.ColumnNameColumn] = value;
133 /// Gets the IsNullable column value
135 public bool IsNullable
141 return ((bool)(this[this._tableTableDetails.IsNullableColumn]));
143 catch (System.InvalidCastException e)
145 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.IsNullableColumn.ColumnName, _tableTableDetails.TableName, e);
150 this[this._tableTableDetails.IsNullableColumn] = value;
155 /// Gets the DataType column value
157 public string DataType
163 return ((string)(this[this._tableTableDetails.DataTypeColumn]));
165 catch (System.InvalidCastException e)
167 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.DataTypeColumn.ColumnName, _tableTableDetails.TableName, e);
172 this[this._tableTableDetails.DataTypeColumn] = value;
177 /// Gets the MaximumLength column value
179 public int MaximumLength
185 return ((int)(this[this._tableTableDetails.MaximumLengthColumn]));
187 catch (System.InvalidCastException e)
189 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.MaximumLengthColumn.ColumnName, _tableTableDetails.TableName, e);
194 this[this._tableTableDetails.MaximumLengthColumn] = value;
199 /// Gets the DateTime Precision column value
201 public int DateTimePrecision
207 return ((int)(this[this._tableTableDetails.DateTimePrecisionColumn]));
209 catch (System.InvalidCastException e)
211 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.DateTimePrecisionColumn.ColumnName, _tableTableDetails.TableName, e);
216 this[this._tableTableDetails.DateTimePrecisionColumn] = value;
222 /// Gets the Precision column value
230 return ((int)(this[this._tableTableDetails.PrecisionColumn]));
232 catch (System.InvalidCastException e)
234 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.PrecisionColumn.ColumnName, _tableTableDetails.TableName, e);
239 this[this._tableTableDetails.PrecisionColumn] = value;
244 /// Gets the Scale column value
252 return ((int)(this[this._tableTableDetails.ScaleColumn]));
254 catch (System.InvalidCastException e)
256 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.ScaleColumn.ColumnName, _tableTableDetails.TableName, e);
261 this[this._tableTableDetails.ScaleColumn] = value;
266 /// Gets the IsServerGenerated column value
268 public bool IsIdentity
274 return ((bool)(this[this._tableTableDetails.IsIdentityColumn]));
276 catch (System.InvalidCastException e)
278 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.IsIdentityColumn.ColumnName, _tableTableDetails.TableName, e);
283 this[this._tableTableDetails.IsIdentityColumn] = value;
288 /// Gets the IsServerGenerated column value
290 public bool IsServerGenerated
296 return ((bool)(this[this._tableTableDetails.IsServerGeneratedColumn]));
298 catch (System.InvalidCastException e)
300 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.IsServerGeneratedColumn.ColumnName, _tableTableDetails.TableName, e);
305 this[this._tableTableDetails.IsServerGeneratedColumn] = value;
310 /// Gets the IsPrimaryKey column value
312 public bool IsPrimaryKey
318 return ((bool)(this[this._tableTableDetails.IsPrimaryKeyColumn]));
320 catch (System.InvalidCastException e)
322 throw EDesignUtil.StonglyTypedAccessToNullValue(_tableTableDetails.IsPrimaryKeyColumn.ColumnName, _tableTableDetails.TableName, e);
327 this[this._tableTableDetails.IsPrimaryKeyColumn] = value;
332 /// Determines if the Catalog column value is null
334 /// <returns>true if the value is null, otherwise false.</returns>
335 public bool IsCatalogNull()
337 return this.IsNull(this._tableTableDetails.CatalogColumn);
341 /// Determines if the Schema column value is null
343 /// <returns>true if the value is null, otherwise false.</returns>
344 public bool IsSchemaNull()
346 return this.IsNull(this._tableTableDetails.SchemaColumn);
350 /// Determines if the DataType column value is null
352 /// <returns>true if the value is null, otherwise false.</returns>
353 public bool IsDataTypeNull()
355 return this.IsNull(this._tableTableDetails.DataTypeColumn);
359 /// Determines if the MaximumLength column value is null
361 /// <returns>true if the value is null, otherwise false.</returns>
362 public bool IsMaximumLengthNull()
364 return this.IsNull(this._tableTableDetails.MaximumLengthColumn);
368 /// Determines if the Precision column value is null
370 /// <returns>true if the value is null, otherwise false.</returns>
371 public bool IsPrecisionNull()
373 return this.IsNull(this._tableTableDetails.PrecisionColumn);
377 /// Determines if the DateTime Precision column value is null
379 /// <returns>true if the value is null, otherwise false.</returns>
380 public bool IsDateTimePrecisionNull()
382 return this.IsNull(this._tableTableDetails.DateTimePrecisionColumn);
387 /// Determines if the Scale column value is null
389 /// <returns>true if the value is null, otherwise false.</returns>
390 public bool IsScaleNull()
392 return this.IsNull(this._tableTableDetails.ScaleColumn);
396 /// Determines if the IsIdentity column value is null
398 /// <returns>true if the value is null, otherwise false.</returns>
399 public bool IsIsIdentityNull()
401 return this.IsNull(this._tableTableDetails.IsIdentityColumn);
405 /// Determines if the IsIdentity column value is null
407 /// <returns>true if the value is null, otherwise false.</returns>
408 public bool IsIsServerGeneratedNull()
410 return this.IsNull(this._tableTableDetails.IsServerGeneratedColumn);
413 public string GetMostQualifiedTableName()
415 string name = string.Empty;
416 if (!IsCatalogNull())
423 if (name != string.Empty)
430 if (name != string.Empty)
435 // TableName is not allowed to be null
441 public EntityStoreSchemaGenerator.DbObjectKey CreateDbObjectKey(EntityStoreSchemaGenerator.DbObjectType objectType)
443 return new EntityStoreSchemaGenerator.DbObjectKey(
444 this[this._tableTableDetails.CatalogColumn],
445 this[this._tableTableDetails.SchemaColumn],
446 this[this._tableTableDetails.TableNameColumn],