locked
How can I order the columns/fields of an Entity RRS feed

  • Question

  • User1929428035 posted

    I have an Entity in which one of the primitive columns is being displayed between the navigation columns. How can I fix this?

    Monday, September 23, 2013 3:13 AM

Answers

  • User-330204900 posted

    I am assuming you are using Dynamic Data, if so you can use the Display attribute to set the Order.

    [Display(Order = 0)]

    add one to each property and the you will set the display order.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 6:47 AM

All replies

  • User-933407369 posted

    hi mr41971,

    From what I understand you want to order the columns/fields of an Entity.you only need to rename columns/fields in an Entity.

    If you use Linq to Entity, I would suggest you to try the following workaround:

    C#:
    
    var query =
    
            from contact in contacts
    
            from order in orders
    
            where contact.ContactID == order.Contact.ContactID
    
                && order.TotalDue < totalDue
    
            select new
    
            {
    
                ContactID = contact.ContactID,
    
                LastName = contact.LastName,
    
                FirstName = contact.FirstName,
    
                OrderID = order.SalesOrderID,
    
                Total = order.TotalDue
    
            };
    
     
    
    VB:
    
    Dim query = _
    
            From contact In contacts _
    
            From order In orders _
    
            Where contact.ContactID = order.Contact.ContactID _
    
                    And order.TotalDue < totalDue _
    
            Select New With _
    
            { _
    
                .ContactID = contact.ContactID, _
    
                .LastName = contact.LastName, _
    
                .FirstName = contact.FirstName, _
    
                .OrderID = order.SalesOrderID, _
    
                .Total = order.TotalDue _
    
            }
    

    I hope it helps you.

    Tuesday, September 24, 2013 5:22 AM
  • User-330204900 posted

    I am assuming you are using Dynamic Data, if so you can use the Display attribute to set the Order.

    [Display(Order = 0)]

    add one to each property and the you will set the display order.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 6:47 AM
  • User1929428035 posted

    Thanks Steve.

    Tuesday, September 24, 2013 11:38 AM
  • User1929428035 posted

    Are'nt all posts to this forum supposed to be related to dynamic data?

    Wednesday, September 25, 2013 1:57 AM
  • User-330204900 posted

    Are'nt all posts to this forum supposed to be related to dynamic data?

    No we get lots of MVC and SQL post here

    Wednesday, September 25, 2013 6:46 AM
  • User1929428035 posted

    Data Scaffolding using ASP.NET Dynamic Data

    Does Data Scaffolding fall within those other area?

    Wednesday, September 25, 2013 7:10 AM
  • User-330204900 posted

    Not really Dynamic Data as it is is only in Web Forms at the moment there are some feature in MVC that are based on DD but the posts should be in the correct forum this is a Web Forms forum :)

    Wednesday, September 25, 2013 8:37 AM