0

Take a look at the following UI:

ui mockup

I am allowing the user, who owns an auto shop of some kind, to select what types of service his shop provides. There are 5 levels to my hierarchy and thousands of total entries. Selecting (checking) any skill area automatically selects all sub-areas or child areas. Each area has an ID which for the top level looks like 10000, the next level 11000, etc...

My questions:

  1. How can I achieve this UI with one code base supporting mobile, tablet and desktop interfaces?
  2. How can I represent the hierarchy using Entity Framework for populating the hierarchy as well as storing the user's selections?

The application is in ASP.Net MVC 4 using SimpleMembership.

4

1 回答 1

0
  1. 让一个代码库支持多个平台的最佳方法是将 ASP.NET MVC 4 WebAPI(JSON 或 XML)用作 REST Web 服务。你可以在这里找到更多关于它的信息:http ://www.asp.net/web-api

还有一些现成的解析器可以将 JSON/XML 数据反序列化为客户端的 C# 对象。

第二个问题似乎与实体框架抽象背后的数据库模式更相关。就 EF 而言,组织数据的最佳方式可能是让类别引用其他类别,最后一个类别引用实际服务。您熟悉数据库关系、外键等概念吗?

编辑:

    public class Category1{
    public string Name { get; set; }

    public virtual ICollection<Item> Items { get; set; }
}

public class Category2{
    public string Name { get; set; }

    public Category1 ParentCategory { get; set; }

    public virtual ICollection<Item> Items { get; set; }
}

public class Item{
    public string Name { get; set; }
    public decimal Price { get; set; }
}

这是一个示例,您将如何编写代码优先的 EntityFramework 对象。Category2 有一个 Category1 类型的父类,并且两个类别都包含一个项目集合。Pluralsight 有一个关于 EF 代码优先的优秀课程,涵盖了所有基础知识。

于 2013-04-20T21:42:03.007 回答