Simple is better

Let's make a comparison between QueryTalk and Entity Framework.
Check this short video!

Load the first person, change the date of birth and update it:


QueryTalk
    var person = s.Person.GoAt(1);
    person.DateOfBirth = DateTime.Parse("1975-06-20");
    person.UpdateGo();
Entity Framework
    using (var ctx = new EntityFrameworkDemo.QueryTalkBaseEntities())
    {
        var person = ctx.Person.Find(1);
        person.DateOfBirth = DateTime.Parse("1975-06-20");
        ctx.SaveChanges();
    }

We want all persons born in the country with most companies, check the sub result & the result:


QueryTalk
    var persons = s.Person.BelongingTo(s.Country
        .WhichHas(s.Most, s.City.Address.Company.JoinAs(s.City))
            .Test())
        .Test().Go();
Entity Framework
    using (var ctx = new EntityFrameworkDemo.QueryTalkBaseEntities())
    {
        var countries =
            from a in ctx.Company
            group a by a.Address.City.Country into g
            select new
            {
                Country = g.Key,
                Count = g.Count()
            };

        var countriesMax = countries
            .Where(a => a.Count == countries.Max(b => b.Count))
            .Select(a => a.Country.CountryID);

        var persons = ctx.Person
            .Where(a => countriesMax.Contains(a.Country.CountryID))
            .ToList();
    }

Load all employed persons and insert their id, first name & last name into another database:


QueryTalk
    d.As().TruncateTable(s2.Employed).ConnectBy("db2").Go();
    var rows = d.PackRows<s2.Data.Employed>(s.Person.WhichHas(s.Job)
        .Go());
    d.ConnectBy("db2").InsertRowsGo(rows);
Entity Framework
    using (var ctx = new EntityFrameworkDemo.QueryTalkBaseEntities())
    {
        var employed = ctx.Person
            .Where(a => a.PersonJob
                .Where(b => b.Job != null)
                .Any());

        using (var ctx2 = new EntityFrameworkDemo.TestEntities())
        {
            var persons = ctx2.Employed;
            ctx2.Employed.RemoveRange(persons);
            foreach (var e in employed)
            {
                var person = new EntityFrameworkDemo.Employed()
                {
                    PersonID = e.PersonID,
                    FirstName = e.FirstName,
                    LastName = e.LastName
                };
                ctx2.Employed.Add(person);
                ctx2.SaveChanges();
            }
        }
    }


Be simple. Be faster. Be smarter.
Join us!

Share QueryTalk with your friends!