locked
Columns not displayed RRS feed

  • Question

  • User-448402197 posted

    I've made a simple dynamic data web site with my database schema, using Entity Data Model. The problem is that some columns are not displayed in the List view.

    Here is the table definition:

     

    1    /// <summary>
    2        /// There are no comments for OdralModel.Geocoding in the schema.
    3        /// </summary>
    4        /// <KeyProperties>
    5        /// Id
    6        /// </KeyProperties>
    7        [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="OdralModel", Name="Geocoding")]
    8        [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
    9        [global::System.Serializable()]
    10       public partial class Geocoding : global::System.Data.Objects.DataClasses.EntityObject
    11       {
    12           /// <summary>
    13           /// Create a new Geocoding object.
    14           /// </summary>
    15           /// <param name="id">Initial value of Id.</param>
    16           public static Geocoding CreateGeocoding(int id)
    17           {
    18               Geocoding geocoding = new Geocoding();
    19               geocoding.Id = id;
    20               return geocoding;
    21           }
    22           /// <summary>
    23           /// There are no comments for Property Id in the schema.
    24           /// </summary>
    25           [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
    26           [global::System.Runtime.Serialization.DataMemberAttribute()]
    27           public int Id
    28           {
    29               get
    30               {
    31                   return this._Id;
    32               }
    33               set
    34               {
    35                   this.OnIdChanging(value);
    36                   this.ReportPropertyChanging("Id");
    37                   this._Id = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
    38                   this.ReportPropertyChanged("Id");
    39                   this.OnIdChanged();
    40               }
    41           }
    42           private int _Id;
    43           partial void OnIdChanging(int value);
    44           partial void OnIdChanged();
    45           /// <summary>
    46           /// There are no comments for Property Street in the schema.
    47           /// </summary>
    48           [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
    49           [global::System.Runtime.Serialization.DataMemberAttribute()]
    50           public string Street
    51           {
    52               get
    53               {
    54                   return this._Street;
    55               }
    56               set
    57               {
    58                   this.OnStreetChanging(value);
    59                   this.ReportPropertyChanging("Street");
    60                   this._Street = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
    61                   this.ReportPropertyChanged("Street");
    62                   this.OnStreetChanged();
    63               }
    64           }
    65           private string _Street;
    66           partial void OnStreetChanging(string value);
    67           partial void OnStreetChanged();
    68           /// <summary>
    69           /// There are no comments for Property City in the schema.
    70           /// </summary>
    71           [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
    72           [global::System.Runtime.Serialization.DataMemberAttribute()]
    73           public string City
    74           {
    75               get
    76               {
    77                   return this._City;
    78               }
    79               set
    80               {
    81                   this.OnCityChanging(value);
    82                   this.ReportPropertyChanging("City");
    83                   this._City = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
    84                   this.ReportPropertyChanged("City");
    85                   this.OnCityChanged();
    86               }
    87           }
    88           private string _City;
    89           partial void OnCityChanging(string value);
    90           partial void OnCityChanged();
    91           /// <summary>
    92           /// There are no comments for Property ZipCode in the schema.
    93           /// </summary>
    94           [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
    95           [global::System.Runtime.Serialization.DataMemberAttribute()]
    96           public string ZipCode
    97           {
    98               get
    99               {
    100                  return this._ZipCode;
    101              }
    102              set
    103              {
    104                  this.OnZipCodeChanging(value);
    105                  this.ReportPropertyChanging("ZipCode");
    106                  this._ZipCode = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
    107                  this.ReportPropertyChanged("ZipCode");
    108                  this.OnZipCodeChanged();
    109              }
    110          }
    111          private string _ZipCode;
    112          partial void OnZipCodeChanging(string value);
    113          partial void OnZipCodeChanged();
    114          /// <summary>
    115          /// There are no comments for Property Country in the schema.
    116          /// </summary>
    117          [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
    118          [global::System.Runtime.Serialization.DataMemberAttribute()]
    119          public string Country
    120          {
    121              get
    122              {
    123                  return this._Country;
    124              }
    125              set
    126              {
    127                  this.OnCountryChanging(value);
    128                  this.ReportPropertyChanging("Country");
    129                  this._Country = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
    130                  this.ReportPropertyChanged("Country");
    131                  this.OnCountryChanged();
    132              }
    133          }
    134          private string _Country;
    135          partial void OnCountryChanging(string value);
    136          partial void OnCountryChanged();
    137          /// <summary>
    138          /// There are no comments for Property Latitude in the schema.
    139          /// </summary>
    140          [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
    141          [global::System.Runtime.Serialization.DataMemberAttribute()]
    142          public global::System.Nullable<double> Latitude
    143          {
    144              get
    145              {
    146                  return this._Latitude;
    147              }
    148              set
    149              {
    150                  this.OnLatitudeChanging(value);
    151                  this.ReportPropertyChanging("Latitude");
    152                  this._Latitude = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
    153                  this.ReportPropertyChanged("Latitude");
    154                  this.OnLatitudeChanged();
    155              }
    156          }
    157          private global::System.Nullable<double> _Latitude;
    158          partial void OnLatitudeChanging(global::System.Nullable<double> value);
    159          partial void OnLatitudeChanged();
    160          /// <summary>
    161          /// There are no comments for Property Longitude in the schema.
    162          /// </summary>
    163          [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
    164          [global::System.Runtime.Serialization.DataMemberAttribute()]
    165          public global::System.Nullable<double> Longitude
    166          {
    167              get
    168              {
    169                  return this._Longitude;
    170              }
    171              set
    172              {
    173                  this.OnLongitudeChanging(value);
    174                  this.ReportPropertyChanging("Longitude");
    175                  this._Longitude = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
    176                  this.ReportPropertyChanged("Longitude");
    177                  this.OnLongitudeChanged();
    178              }
    179          }
    180          private global::System.Nullable<double> _Longitude;
    181          partial void OnLongitudeChanging(global::System.Nullable<double> value);
    182          partial void OnLongitudeChanged();
    183      }
    

     

    Only the Id, Latitude and Longitude columns are displayed... But all columns are displayed in Detail view.

     

    Friday, December 5, 2008 11:48 AM

Answers

  • User-1005219520 posted

    max) type? Because the columns that are not displayed are these ones (I've refreshed the model because I've added StatusCode and Accuracy and these integer columns are displayed) 

    Yes, that's exactly why. They should show up in details view but not list view. Change [nvarchar](max)  to something more reasonable (you don't need a zipcode or country that large) and they will show up. A [nvarchar](max)  would be too large to show by default.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 5, 2008 4:41 PM
  • User1641955678 posted

    Note that this behavior can be overriden with a custom IAutoFieldGenerator.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 8, 2008 2:54 PM

All replies

  • User-330204900 posted

    With out knowing your table definition to compare to the definition of the model I can't say, but what I can say is EF mostly hide FK's in the Entity and only shows the EntityRef or with Children Relationships it show an EntitySet.

    Hope this helps [:D]

    Friday, December 5, 2008 12:07 PM
  • User-448402197 posted

    My table schema is very simple, no relationships:

    CREATE TABLE [dbo].[Geocoding](
     [Id] [int] IDENTITY(1,1) NOT NULL,
     [Street] [nvarchar](max) NULL,
     [City] [nvarchar](max) NULL,
     [ZipCode] [nvarchar](max) NULL,
     [Country] [nvarchar](max) NULL,
     [Latitude] [float] NULL,
     [Longitude] [float] NULL,
     [StatusCode] [int] NULL,
     [Accuracy] [int] NULL,
     CONSTRAINT [PK_Geocoding] PRIMARY KEY CLUSTERED
    (
     [Id] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]

    Could the problem come from the nvarchar(max) type? Because the columns that are not displayed are these ones (I've refreshed the model because I've added StatusCode and Accuracy and these integer columns are displayed) 

     

    Friday, December 5, 2008 12:34 PM
  • User-330204900 posted

    Could the problem come from the nvarchar(max) type? Because the columns that are not displayed are these ones

    Yes that would be the reason as these are automatically set to ScffoldColumn(false) so in your metadata you will need to annotate them like so:

     

    [MetadataType(typeof(Geocoding_Metadata))]
    public partial class Geocoding
    {
        public class Geocoding_Metadata
        {
            [ScaffoldColumn(true)]
    public object Country { get; set; }
         }
     }
    This column will now show [:D]
     
    Friday, December 5, 2008 1:21 PM
  • User-448402197 posted

    still not displayed [:'(]

    I've also added:

    [ScaffoldColumn(false)]
    public object Id { get; set; }

    and now the Id column is not visible ; so my partial class is taken into account...  

     

     
    Friday, December 5, 2008 3:20 PM
  • User-1005219520 posted

    max) type? Because the columns that are not displayed are these ones (I've refreshed the model because I've added StatusCode and Accuracy and these integer columns are displayed) 

    Yes, that's exactly why. They should show up in details view but not list view. Change [nvarchar](max)  to something more reasonable (you don't need a zipcode or country that large) and they will show up. A [nvarchar](max)  would be too large to show by default.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 5, 2008 4:41 PM
  • User1641955678 posted

    Note that this behavior can be overriden with a custom IAutoFieldGenerator.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 8, 2008 2:54 PM