Save Entity Framework Linq Query to database

后端 未结 4 622
逝去的感伤
逝去的感伤 2020-12-17 05:28

I was wondering if we can convert a Linq Query on the Entity Framework and save the query to the database by converting it to an Expression Tree and Serializing. Can someone

4条回答
  •  囚心锁ツ
    2020-12-17 05:44

    i released a library for that purpose just yesterday. Serialize.Linq. It serializes linq expressions to xml, json or binary.

    using System.Linq.Expressions
    using Serialize.Linq.Extensions;
    
    Expression> query = p => p.LastName == "Miller" 
        && p.FirstName.StartsWith("M");
    
    Console.WriteLine(query.ToJson());
    Console.WriteLine(query.ToXml());
    

提交回复
热议问题