请注意以下内容中的数据、格式都是pseudo data,不要对格式、具体的名字、数据花太多精力。 问题描述: 我们的数据库里面的表都是动态的。也即表的数量、名字都是根据客户需要动态的建立的。这些表的关系由一个ResourceAttributes表管理。比如: 如果用户需要定义一个关于书的表,他可以定义一个attribute叫做Book Details,数据库里就会为这个Attribute自动建一个表: tbl_Book_Details。ResourceAttributes表里面就会有一条记录row1,比方说,row1 { resourceClass = Book; Attribute = Book Details; AttributeTable = tbl_Book_Details } 有没办法对这样的架构使用RIA service?我觉得那些个Domain Service都是针对固定的database schema建立的。象我们这样的动态的database schema不好用。 你们对这样的状况是如何处理的?如何定义一个中间层从而可以使用RIA、Entity Framework或者RESTful web service against dynamically created database schema? What I really wanted, are the access to the data stored in these dynamically created tables without knowing the table name at the design time. First I have to run a query against the ResourceAttributes table to get all the attributes for a given class Book. 目标描述: 我想写一些generic的RESTful web service来管理这些存在各个Attribute表里的数据。 比如: GET /Resource/Book/{id} 我期待拿到一个JSon格式的result, 我这里就举一些个简单的: book {_id = 1; Name = Call Of Duty; Book Details: {_id = 1; Platform = XBOX360; Media = CD}; Book Publisher: {_id = 1; Publisher = Activision}} 再比如: GET /Resource/Book, I expect a list of books in the above-mentioned format 再比如: PUT /Resource/Book/{id} 就相当于update a book object with given data. etc. 但由于这些resource classes和Attributes都是用户定义的,除非query against ResourceAttribute这些表不可能在设计的时候知道这些resource class以及它们的Attribute的名字。这个service就不太好写。 [ 本帖最后由 混不到坑的萝卜 于 2010-10-25 14:29 编辑 ] |