How to develop MS CRM kind of application

对着背影说爱祢 提交于 2019-12-24 03:48:18

问题


I have worked with MS CRM. There we can design our custom entity graphically and then we can also build a visual form to perform CRUD operations on that entity.

This feels so simple from end user's perspective. However I am interested to know how can I develop the similar kind of application where I design my table on the fly and the design UI on the fly.

What I want to know is like how do they achieve all of this dynamically? If I have to create CRUD on one simple table, I need to write good amount of code. How MS achieves everything on the fly? Any pointers, any document would be of great help.


回答1:


I have no idea how they actually do it, but if it were me I'd use attributes and reflection.

Here's how I think it'd probably work / or rougthly how you could do it...

Components

The system would need a bunch of components or sub-systems; they coudl be stuff you write yourself or existing libraries (use existing libraries if you can):

  • A CMS of somekind, unless you want to build this into a system you already have.
  • A UI component / control that lets users make their "objects". To be done well this would require a fairly advanced UI (SilverLight? HTML5?) - although I guess you could use something really basic.
  • Some way of storing the users "objects" - this is bascially data, and you'd want to keep it stored in a "neutral" repository of some kind.
  • Something that does the actual CRUD - I'm thinking some sort of ORM tool like Entity Framework, Lightspeed, NHibernate. You'll also need a datasource target for the CRUD operations themselves.

The trick is in points 2 and 3; this is where I'd define a set of Attributes that could be used to define the user created objects. These attributes are what logically joins the process together. Because Attributes can be read at runtime:

  • They'll be able to drive the UI that allows users to compose their "objects".
  • When ready, you could generate actual classes that physically implement the user defined objects - and then decorate those objects with the appropriate attributes.
  • Somehow have the ORM tool know how to map the properties of those objects (based on the attributes) to the datastore, or, write the DAL yourself - maybe you're DAL would wrap an ORM?

Another approach I've used is based pretty much on this but it also makes use of interfaces, and the data is stored as a "blob" of XML - not specific discrete metadata.



来源:https://stackoverflow.com/questions/3766708/how-to-develop-ms-crm-kind-of-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!