Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
592 views
in Technique[技术] by (71.8m points)

c# - Serialize.Linq does not work in WCF proxy layer

I use Serialize.Linq for send and receive Expression<Func<>> query between Client and Server in WCF Application service because Expression<Func<>> can not be serialized

all things seems ok BUT

when I add reference this library to wcf proxy layer and add server reference my web service

when build my project get errors like these

ExpressionNodeOfNewExpressionQsd8_SODT' does not implement inherited abstract member 'Serialize.Linq.Nodes.ExpressionNode.ToExpression(Serialize.Linq.ExpressionContext)'

ExpressionNodeOfTypeBinaryExpressionQsd8_SODT' does not implement inherited abstract member 'Serialize.Linq.Nodes.ExpressionNode.ToExpression(Serialize.Linq.ExpressionContext)'

etc ...

seems WCF create auto-generated proxy classes for this library instead of using main classes while I add reference Serialize.Linq assembly to proxy project but no help to solve my problem

You can test and show this problem very simply

like this

  1. Create Wcf Service Application and Add reference Serialize.Linq to project

    public interface IService1
    {
      [OperationContract(Name = "GetByPredicate")]
      List<Person> Get(ExpressionNode expression);
      [OperationContract]
      List<Person> Get();
    }
    
    
    public class Person
    {
      public int ID { get; set; }
      public string Name { get; set; }
    }
    
    public class Service1 : IService1
    {
      private List<Person> _persons;
      public Service1()
        {
        var p = new List<Person>
        {
            new Person() {ID = 1, Name = "A"},
            new Person() {ID = 2, Name = "B"},
            new Person() {ID = 3, Name = "C"},
            new Person() {ID = 4, Name = "D"},
            new Person() {ID = 5, Name = "E"},
            new Person() {ID = 6, Name = "F"},
            new Person() {ID = 7, Name = "G"},
            new Person() {ID = 8, Name = "H"}
        };
    
        _persons = p;
    }
    public List<Person> Get(ExpressionNode expression)
    {
        var ex = expression.ToExpression<Func<Person, bool>>().Compile();
        return _persons.Where(ex).ToList();
    }
    
    public List<Person> Get()
    {
        return _persons;
    }
    }
    
  2. Create Class Library Project and Add reference Serialize.Linq to project

  3. Add above Wcf Service as Service reference this this Class library as Wcf proxy project
  4. Now Build project , You can see errors !!! :(

Any Ideas ?!, How use Serialize.Linq library in proxy layer ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...