简体   繁体   中英

Order a select by Name and id (ELEVATEDB)

I Have a table named families, where i have nested families of products. All the entries of the table that have a length lower than 5, are parent families, and the families with a length of 5, are families with associated products. For example: ID Name

001    food 
00101  cookies
002    Cars
00201  ferrari
003    bike
00301  yamaha

Thats an example of my Db. I want to represent it on mvc c# list. But the problem is, that I need to group it by Id, and order it by name too. For example, I would like to have:

003 bike
00301 yamaha
002 Cars
00201 ferrari
001    food 
00101  cookies

What I want to order alphabetically is the name of parent Families (Bike,Cars,Food).

I'm using ElevateDb and MVC 4 c# in the other side, maybe, there is a way to do it in the c# list too.

This is a very poor database design. You should consider creating a separate Families table:

001 food
002 cars
003 bike

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM