Skip to content

Subkey query

QQ edited this page Sep 30, 2022 · 4 revisions

Build mock

RegQuery<Computer> regt_computer = new RegQuery<Computer>()
    .useSetting(x =>
    {
        x.Hive = RegistryHive.CurrentConfig;
        x.SubKey = @"LikeDB_SubKey\Computers";
        x.View = RegistryView.Registry64;
    });
var computers = Enumerable.Range(1, 10).Select(x => new Computer()
{
    Name = $"Computer_{x}",
    Ram = new Ram()
    {
        Manufacturer = $"Ram{x}",
        Size = (int)Math.Pow(x,2)
    },
    NetworkCard = new NetworkCard()
    {
        Manufacturer = $"NetworkCard{x}",
        Address = new Address1()
        {
            IP = $"127.0.0.{x}",
            Port = x+80
        }
    },
    Size = new Size() {Width=x+1, Height=x+2 }
});
regt_computer.RemoveAll();
regt_computer.Insert(computers);

Where expamle

var sss = regt_computer.Where(x => x.Size.Width+x.Size.Height < 10);
Clone this wiki locally