This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, can someone help me with building a query where I have many to many association (through) and I don't know how many elements I will be selecting. Here: http://www.mindscape.co.nz/blog/index.php/2009/06/08/join-queries-in-lightspeed-2/ is example with searching certain tags. My problem is that I don't know how many tags (like in example) will be selected for showing. I know that in my app I will have int array (categories IDs) and I must search for products which can be associated to multiple categories (that's why there is many-to-many association). Thanks in advance P.S. It's 1AM so right now I'm not sure if this is a big problem or I'm just tired :) |
|
|
You should be able to use a .In query (in the core API) or the Contains method (in LINQ). E.g. IEnumerable<string> tags = new List<string> { "sheep", "cabbages" } var ooarr = from ct in UnitOfWork.ContributionTags We had some limitations in 3.0 RTM with Contains handling so if you run into problems please be sure you are using a recent nightly. |
|
|
This will not work for me :/ Maybe I've described it wrong. Scenario: Tables (to make it simple I've added only needed properties):
One product can be inside more than one category. They are connected with each other using auto through entity called ProductsCategory and now I don't know how to put in one LINQ query param which is array of int containing searched categories (I'm looking for certain product name inside certain categories). |
|
|
int[] categories = new int[] { 2, 3, 5, 7 }; var query = from pc in UnitOfWork.ProductCategories This will return all products which are in any of the categories in the array and whose name matches the one you're asking for. Or am I still misunderstanding the requirement? |
|