locked
How to integrate existing domain classes into Lightswitch RRS feed

  • Question

  • Hi,

    We have a domain model comprised of existing c# classes with typical clases such as Customer, Products, Invoices etc.

    What is the best way to use this domain model in a LS - Application?

    What are the best working design patterns to accomplish this integration?

    I saw Julie's Lerman course in pluralsight.com "Entity Framework: Code First" and it is amazing how easily it is to create a data layer in minutes out of existing domain classes using annotations or the fluent API of entity framework. But in order to have a complete working applications there are the other layers missing.

    Any advice would be really appreciated.

    Best regards,

    Jean Pierre Chauny

    Sunday, November 17, 2013 3:54 PM

Answers

  • If you let LS provide the domain (simply the out-of-the-box experience), you use that domain model.

    If you provide your own domain model (and attach to it via ria services), you use that model.

    Mixing them is a bad idea. A domain model is not only about validations, but also e.g. unit of work pattern: only one model at a time can be responsible for correctly saving an entity graph.


    paul van bladel

    Monday, November 18, 2013 8:31 AM

All replies

  • Indeed, entity framework code first is great, but it's only one part of the puzzle of a complete line of business framework.

    In LightSwitch, server side, you could just use another entity framework model, but the usage would be limited to server side processing only. So, you can not use the model as a base for creating screens. But you could use the EF domain model in a separate Ria Service. In case you want to create screens based on the domain model, you better attach directly to the database. LightSwitch will generate classes which look quite similar to what EF generates for you.


    paul van bladel

    Sunday, November 17, 2013 9:56 PM
  • Thank you Paul. I don't have experience in RIA Services, I'm going to study it. In order to create screens I like the idea of attaching from LS to the database created by EF. But how can I use the calculation methods from my domain classes inside of LS? I mean: what is the design pattern used to map my domain classes to the LS entities? Jean Pierre Chauny
    Monday, November 18, 2013 3:52 AM
  • If you let LS provide the domain (simply the out-of-the-box experience), you use that domain model.

    If you provide your own domain model (and attach to it via ria services), you use that model.

    Mixing them is a bad idea. A domain model is not only about validations, but also e.g. unit of work pattern: only one model at a time can be responsible for correctly saving an entity graph.


    paul van bladel

    Monday, November 18, 2013 8:31 AM