This Forum is ARCHIVE only
For LightSwitch questions,
please use the official forums at:

Question: how to remove new entities from autocomplete with query
Last Post 12 Jun 2013 06:57 PM by Johan Hazendonk. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
JohanUser is Offline
New Member
New Member
Send Private Message

12 Jun 2013 06:57 PM

    I would like some help with the following:

    I have an entity  named ContentItem which contains a type specifier (FK to ItemType tabel) , and a name as string.
    Each entity can have a reference to another ContentItem so I made a 0..1 to n relation to itself.

    The model is displayed at the top of the first image in the picture below.

    There needs to be a business rule that a ContentItem can only be linked to ItemTypes of another type. E.g. ItemType 1 to ItemType 2.

    So first I made a editable grid screen editing itemtypes.

    Then I design a grid / details screen where in a dropdown the user needs to select an item to be linked.

    The screen looks as the second image in the picture below

    In order to have the dropdown show only the linked Items I made a query as a child from ContentItems, call it ItemsAvailableToLink and retrieves as parameter the selected ItemType in the screen.

    In the Preprocess Query I change the query to the following:

         partial void ItemsAvailableToLink_PreprocessQuery(int? ItemTypeId, ref IQueryable query)


                if (ItemTypeId != null)

                    query = query.Where(x => x.ItemType.ItemTypeId != (int)ItemTypeId);

                query = query.Where(x => x.LinkedItem.ItemId == null);


     I run the software and everything seems to work fine as you can see in the first picture of the next picture

    However When I add an item It will immediately, even before saving the item ) show up in the list of items to be linked. It is possible to net let it show up immediately but when you click the refresh button is shows up.

    See the second image in the following picture.

    It seems like the Items dataset and the LinkedItems dataset are related.

    The question is:
    How can I make this such that these new items do not show in the list even when the refresh button is clicked?

    You are not authorized to post a reply.

    Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation