The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Sorting a Extended property returns non object error

Last post 11-07-2007, 5:21 PM by Mike.Griffin. 4 replies.
Sort Posts: Previous Next
  •  07-05-2007, 11:28 PM 3619

    Sorting a Extended property returns non object error

    Hi there,

    I have added an extra column (property to my es class.

    Next i tryd to hook ik up to the esDatasource. This works fine except for one thing. Sorting.

    When ik click the header to sort this column I get a Object reference not set to an instance of an object error.

    I am using es 2007 and the data for the extended prop comes from a view with an inner join to get the data for the extra prop.

    Here is the code:

    asp:

    Code:
    <asp:BoundField DataField="BrandName" HeaderText="BrandName" InsertVisible="False" ReadOnly="True" SortExpression="BrandName" />
    
    Code:
    coll.Query.es.QuerySource = "vwCarModel";
    Code:
     public partial class CarModelCollection : esCarModelCollection
        {
            protected override void CreateExtendedProperties(esColumnMetadataCollection extendedProps)
            {
                if (null == extendedProps["BrandName"])
                {
                    esColumnMetadata col = new esColumnMetadata();
                    col = new esColumnMetadata("BrandName", this.Meta.Columns.Count + 1, Type.GetType("System.String"));
                    col.PropertyName = "BrandName";
                    col.IsReadOnly = true;
                    extendedProps.Add(col);
                }
            }
    
        }

    Code:
    public partial class CarModel : esCarModel
        {
            public  string BrandName
            {
                get
                {
                   return base.GetSystemString("BrandName");
                }
            }
        }

     

  •  07-06-2007, 5:16 AM 3635 in reply to 3619

    Re: Sorting a Extended property returns non object error

    I am very glad you posted this when you did, there is a problem here. You will need to create a psuedo column in the DataTable. The problem is the Table property is null when CreateExtendedProperties is called. I will get this working for the July 9th release and post an example with the tested code.  Here is what the code will eventually look like:

    Code:
    protected override void CreateExtendedProperties(esColumnMetadataCollection extendedProps)
    { 
        if (null == extendedProps["MySortableExtendedColumn"]) 
        {
            // Add psuedo column to the real DataTable for sorting/filtering
            this.Table.Columns.Add("MySortableExtendedColumn", Type.GetType("System.String"));
    
            esColumnMetadata col = new esColumnMetadata("MySortableExtendedColumn", this.Meta.Columns.Count + 1, 
                Type.GetType("System.String"));
    
            col.PropertyName = "MySortableExtendedColumn"; 
            col.IsTransient = true; 
            extendedProps.Add(col); 
        } 
    }
     

    We use the DataTable for our sorting and filtering, thus this column needs to exist in the DataTable. However, all this being said, the "FullName" field in the example in the POST would be sortable, so if you're using the Query to get the data you could just add "<' ' as MySortableExtendedColumn>" to your query ?


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-11-2007, 12:22 AM 3782 in reply to 3635

    Re: Sorting a Extended property returns non object error

    Hmm... The field however does get loaded through the view the data is coming from.

    So it should be in the datatable.

    Code:
    coll.Query.es.QuerySource = "vwCarModel";

    wich contains the field for the ext prop.

    And an other thing is that I dont know when 'CreateExtendedProperties' is called because my debugger never hits this code.

    Any Ideas??

    Oh, I use the latest version of es2007 now (9-7-2007) Tanks for the esUtility Connection property.

  •  11-07-2007, 4:17 PM 6383 in reply to 3782

    Re: Sorting a Extended property returns non object error

    I have a similar issue. All the same symptoms as described, and I have tried all the code Mike suggested (see code example below). I am using the esDataSource to populate a gridview. I can display the StockName column in my gridview (by editing the markup code) even though it doesn't come up in the list of available columns for the esDataSource. I have also noticed that when doing:

    StockSummaryCollection stock = new StockSummaryCollection();
    StockSummaryMetadata.PropertyNames.

    I don't get the new property "StockName" listed in intellisense.

    The problem I have is when I try to sort this column in the gridview I get a javascript alert saying "Object reference not set to an instance of an object." But all my other columns sort fine. If I change the column sort to "StockTypeID" it sorts ok, but obviously won't sort by alphabetical StockName.  I am using EntitySpaces 2007 Release. I've searched the forums and I can't find any other examples that help.  I hope I'm just missing something simple?

    Thanks,
    Glenn.

    public partial class StockSummary : esStockSummary
    {
     
    public string StockName
      {
       
    get
       
    {
         
    return this.UpToStockTypeByStockTypeID.Name;
        }
      }
    }

    public partial class StockSummaryCollection : esStockSummaryCollection
    {
     
    protected override void CreateExtendedProperties(esColumnMetadataCollection extendedProps)
      {
       
    if (null == extendedProps["StockName"])
        {
         
    // Add psuedo column to the real DataTable for sorting/filtering
          
    this.Table.Columns.Add("StockName", Type.GetType("System.String")); //I have tried not doing this but it makes no difference
         
    esColumnMetadata col = new esColumnMetadata("StockName", this.Meta.Columns.Count + 1, Type.GetType("System.String"));
          col.PropertyName =
    "StockName";
         
    //col.IsTransient = true; //I have tried this but it makes no difference
         
    extendedProps.Add(col);
        }
      }
    }

  •  11-07-2007, 5:21 PM 6385 in reply to 6383

    Re: Sorting a Extended property returns non object error

    This has all been fixed in our v1024 beta, the CreateExtendedProperties approach is obsolete, see our release notes for 1024. You will never get an error when sorting on a virtual property, however, it might not sort either, I know that our virtual properties sort in DevExpress grids as they sort the data in memory. Sorting on Virtual columns is something that will have to wait (for some grids) until ES2008, however, you wont get an error in v1024 and higher.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML