Skip to content

Entity attributes use string interpolation, and cannot be filtered using where #993

Open

Description

@dalangtk
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Dynamic.Core;

public class Program
{
    public static void Main()
    {
        Test1();

        Console.ReadKey();
    }
    static void Test1()
    {
        List<Persona> list = new List<Persona>();
        var nome = $"ciccio{2}";//nome use string interpolation
        list.Add(new Persona { Nome = "ciccio1", Eta = 10 });
        list.Add(new Persona { Nome = nome, Eta = 11 });
        IQueryable<Persona> ql = list.AsQueryable();

        ql = ql.Where("Nome = @0", "ciccio1");
        Console.WriteLine("ciccio1 count:" + ql.Count());

        var filter = list.FindAll(v => v.Nome == "ciccio2");
        Console.WriteLine("ciccio2 count:" + filter.Count());//using findall can retrieve data,filter.Count = 1

        ql = ql.Where("Nome = @0", "ciccio2");
        Console.WriteLine("ciccio2 count:" + ql.Count());//No data can be retrieved here,ql.Count = 0
    }
}


class Persona
{
    public int Eta { get; set; }
    public string Nome { get; set; }
}
Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions