re: Tutorial: MongoDB With C# The Easy Way! VIEW POST

re: Thanks for answering, you are awesome :) no, I don't want to create two new zones. Zones are like a META table or "Dictionary". I only have 20 z...

for seeding the zone entities once, you can use the migrations feature by first writing a migration class like this:

public class _001_seed_zone_data : IMigration
    public void Upgrade()
        var zones = new List<Zone>();

        for (int i = 1; i <= 20; i++)
            zones.Add(new Zone { SqlId = i });


then on your application startup simply call:


then you can create your searches like this:

    var wantedZones = new[] { 1, 2, 3 };

    var foundZones = DB.Find<Zone>()
                       .Many(z => wantedZones.Contains(z.SqlId));

    var seach1Zones = foundZones.Where(z => new[] { 1, 2 }.Contains(z.SqlId));
    var search2Zones = foundZones.Where(z => new[] { 1, 2, 3 }.Contains(z.SqlId));

    var search1 = new Search();
    var search2 = new Search();

    DB.Save(new[] { search1, search2 });


Thanks, you are very cool. I will try it now

here's my test program in case you need to have a look: gist.github.com/dj-nitehawk/8bde0d...

Thank you :) I bought you a coffee for your outstanding help.

This project has a lot of potentials! I will recommend it to fellow C# devs.

you are most welcome. just received the email notification regarding the donation. much appreciated. if you ever need any more help, just go to the github repo and open up a new issue. i'll be more than glad to help. have a great day!

Code of Conduct Report abuse