Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: what's the best way/practice of handling many to many in C1

$
0
0
The common way is to use IndexOf to see if a list of Guids contains a specific Guid.

I'm not sure if 100% get how your data is structured, but where you would in a normal relational database have a many-to-many datatype containing two fields, this is not what you would do in C1. Instead, if lets say an article is tagged with 5 tags, the Article would have a TagIds property containing a comma-separated list of 5 guids.

If you then need to list all articles tagged with Food, you would do a
var articlesAboutFood = data.Get<IArticle>().Where(a => a.TagIds.IndexOf(food.Id.ToString(), StringComparison.OrdinalIgnoreCase) > -1).ToList();

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>