locked
Query to fill computed protery in Visual Studio LightSwitch VB RRS feed

  • Question

  • Hi,

    I need some help. I have a SQL database with several entities and relationships. I now want to add a Computed Property with the value based on a query of serveral fiels in my Orderdetails. The Query needs to find the matching salesrate in the other Enitity Salesrates.

    Thanks,

    Olivier

    Sunday, January 18, 2015 10:35 AM

All replies

  • Olivier, I already answered your other similar question thinking you needed this when compiling the screen.
    If it's the same topic please a) avoid duplicating questions b) explain better your needs.

    Are you sure you want a computed property? and which value to return? Rate Id or Rate value?
    About computed properties remember that will not be easy to show them on a client screen. I'd say impossible.
    Also, a business consideration: as your app seem to be an ordering system do you think it's correct that when a Rate changes, consequently all old Order Details rates have to change?
    Additionally, querying on multiple related entities could lead to low performance on collections, although server side.

    You should consider saving values permanently in the Order Detail entity (assuming it's the same topic as the other question).

    Anyway, if you add a computed property to your entity, select your property and 'Write Code' on entity designer and choose 'MyComputedPropery_Compute' sub.
    If you'll go with a standard property you can set the value in code for every insert/update, again 'Write Code' in the designer and choose 'MyEntity_Inserting' and _Updating sub.

    In order to write code inside the save pipeline would be useful to learn something here.

    Working server side is all about standard VB.Net stuff once you acces to results of the same query I suggested in the other thread:

    DataWorkspace.ApplicationData.PurchaseRatesSearchQuery(entity.Order.Collectivity, entity.Seller.Id, entity.Model, entity.Type, entity.Option)


    Marco

    • Proposed as answer by technetcolmar Sunday, January 18, 2015 7:57 PM
    Sunday, January 18, 2015 1:21 PM
  • Hi Marco,

    Thanks again. Yes it is about the same build as the other question; sorry about that.  But this is about saving the retreived data.

    You are right... it is not smart to use Computed Properties. I am not sure how to save the data permanently in the order details, but I have asked you about this in the other question; it is better to keep it as one issue, so please ignore this question.

    Olivier

    Sunday, January 18, 2015 7:36 PM