[英]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.
表格中所有长度小于5的条目都是父级家族,长度为5的家族是具有相关产品的家族。 For example: ID Name
例如:ID名称
001 food
00101 cookies
002 Cars
00201 ferrari
003 bike
00301 yamaha
Thats an example of my Db. 那是我的Db的一个例子。 I want to represent it on mvc c# list.
我想在MVC C#列表上代表它。 But the problem is, that I need to group it by Id, and order it by name too.
但是问题是,我需要按ID对其进行分组,并按名称对其进行排序。 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. 我在另一端使用ElevateDb和MVC 4 c#,也许在c#列表中也有这样做的方法。
This is a very poor database design. 这是一个非常差的数据库设计。 You should consider creating a separate Families table:
您应该考虑创建一个单独的家庭表:
001 food 001食物
002 cars 002辆
003 bike 003自行车
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.