Linq.Dynamic条件在哪里

编程入门 行业动态 更新时间:2024-10-25 08:20:51
本文介绍了Linq.Dynamic条件在哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在使用System.Linq.Dynamic库.有没有一种方法可以使用具有一对多关系的实体.具体来说,我有3个班级

Hi, I have been using System.Linq.Dynamic library. Is there a way to use Entities with one to many relationship. To be specific I have 3 classes

class A { public int Id {get;set;} ... ... public Class2 class2 {get;set;} public List< Another > Bs{get;set;} } class Class2 { public int Id{get;set;} } class Another { public int Id {get;set;} }

当一对一的关系时,我可以过滤

I can filter when the relationship is one to one

public IQueryable< T > Select< T >(string condition,object value) { var list=FindAll< T >();//return list of T from database var result=list.Where(string.Format("{0} = @0",condition),value); } result=Select< A >("class2.Id",1);

上面的调用给我列出了class2的id = 1的A对象的列表.我如何搜索该关系是否为一对多..如何根据每个对象的Bs的第一项(即Bs [0])过滤A对象的列表.是否可以使用Linq.Dynamic.

the above call gives me the list of A objects whose class2''s id=1. how can i search if the relationship is one to many.. how do i filter list of A objects based on each object''s first item of Bs ie Bs[0]. would it be possible to filter using Linq.Dynamic.

推荐答案

进行过滤想要满足条件),然后完全按照您给出的示例进行调用. 毕竟,LINQ引擎盖下有一个for循环.因此,您可以使用的逻辑将是相似的. You can possibly implement a property in class A that checks the first item of class2 inside it (or however you want the condition to be), then call this exactly as the example you have given. After all, underneath the hood LINQ does a for loop. So the logic you can use would be similar.

更多推荐

Linq.Dynamic条件在哪里

本文发布于:2023-11-16 21:58:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607632.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条件   Linq   Dynamic

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!