Giter Site home page Giter Site logo

Comments (4)

StefH avatar StefH commented on May 21, 2024

If possible, rebuild your question into a unit-test which can be included in the tests.

from system.linq.dynamic.core.

AndrewZenith avatar AndrewZenith commented on May 21, 2024

That would be difficult as I don't know how to do it. I'll try again though, this is perhaps a simpler example linq query (that works) that I want to do, but can it be done using the join extension using the string parameters?

IQueryable a = from zz in dyn2
join yy in dyn on dyn.Where(xx => xx.JobID == zz.JobID && xx.EventID == "EVENT2").Max(xy => xy.SQL_RFA) equals yy.SQL_RFA
select new { zz, yy };

from system.linq.dynamic.core.

AndrewZenith avatar AndrewZenith commented on May 21, 2024

I've downloaded your source and managed to write an example in the code similar to your join test. Here it is:

using System.Collections.Generic;
using System.Linq.Dynamic.Core.ConsoleTestApp.net452.Entities;

namespace System.Linq.Dynamic.Core.ConsoleTestApp.net452
{
    class Program
    {
        static void Main(string[] args)
        {
            Person magnus = new Person() { id=1, name = "a" };
            Person terry = new Person { id=2, name = "b" };

            Pet barley = new Pet { id = 1, name = "1p1", personid = 1 };
            Pet boots = new Pet { id = 2, name = "1p2", personid = 1  };
            Pet whiskers = new Pet { id = 3, name = "2p1", personid = 2 };


            var people = new List<Person> { magnus, terry };
            var pets = new List<Pet> { barley, boots, whiskers };

            //Act
            var realQuery = people.AsQueryable().Join(
                pets,
                person => 
                pets.Where(x => x.personid == person.id).Max(x => x.id),
                pet => pet.id,
                (person, pet) => new { OwnerName = person.name, Pet = pet.name });

            var realResult = realQuery.ToArray();

            var dynamicQuery = people.AsQueryable().Join(
               pets,
               "???",
               "id",
               "new(outer.name as OwnerName, inner.name as Pet)");

            var dynamicResult = dynamicQuery.ToDynamicArray<DynamicClass>();

        }
    }

    internal class Pet
    {
        public int id { get; set; }
        public int personid { get; set; }
        public string name { get; set; }
    }

    internal class Person
    {
        public int id { get; set; }
        public string name { get; set; }

    }
}

from system.linq.dynamic.core.

StefH avatar StefH commented on May 21, 2024

It's not possible to use external sub-query in a dynamic query.

from system.linq.dynamic.core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.