Picks nomenclature of goods available in all stores RRS feed

  • Question

  • Dear Gurus!

    There are some subset of table Stores (id_shop, name_shop). In table Products (id_product, name_product ) are all available products in shops. And in table ProductsInStores (id, id_shop, id_product, count) - there are counts for each product in shops (if counts>0). How to get nomenclature of all products, available in all shops?

        A subset of stores - the result of filtering the main table. And afterall it is desirable to obtain a list of distincts products , available in subset of stores.

    Thanks in advance!

    PS. I use entity framework and linq to entities. Subset of store is available through CollectionView over ObservableCollection.

    • Edited by ATerentjev Monday, May 27, 2013 6:49 AM
    • Moved by Bob Shen Wednesday, May 29, 2013 9:01 AM
    Monday, May 27, 2013 6:35 AM


All replies

  • try this

    select p.*, s.*,ps.Count() from Products p, Stores s, ProductsInStores ps
    where p.id_product = ps.id_product and ps.Count() > 0

    Faisal Ahmed Farooqui —————————— If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, May 27, 2013 6:52 AM
  • var query = from p in dc.products join ps in dc.productsInStore on p.id_product equals ps.id_product join s in dc.store on s.id_store equals ps.id_store where ps.count>0 select p.id_product; var query1 = query.Distinct();

    I try this code to get a set of distinct products id. But the problem is  to use not dc.store, but collectionView from observableCollection of stores:

    masterObservableCollection = new ObservableCollection<store>(dc.stores);
    masterView = (CollectionView)CollectionViewSource.GetDefaultView(masterObservableCollection);
    masterView.Filter = new Predicate<object>(Contains);

    Monday, May 27, 2013 8:06 AM
  • Hi ATerentjev,

    I think this problem is very similar to this thread. You can use OfType<T>() extension method on the CollectionView:


    If they are the same problem, I would like to close this thread. If there are further updates about this issue, please feel free to let us know.

    Best regards,

    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Chester Hong Wednesday, June 5, 2013 9:41 PM
    Thursday, May 30, 2013 9:11 AM