C# 有人能解释一下吗;存储库-实体“;?
我在读这篇文章: 我看到了这个代码:C# 有人能解释一下吗;存储库-实体“;?,c#,entity-framework,architecture,C#,Entity Framework,Architecture,我在读这篇文章: 我看到了这个代码: public interface IRepository<T> where T : class { void Add(T entity); void Update(T entity); void Delete(T entity); void Delete(Expression<Func<T, bool>> where); IEnumerable<T> Query(Exp
public interface IRepository<T> where T : class
{
void Add(T entity);
void Update(T entity);
void Delete(T entity);
void Delete(Expression<Func<T, bool>> where);
IEnumerable<T> Query(Expression<Func<T, bool>> filter);
IEnumerable<T> QueryObjectGraph(Expression<Func<T, bool>> filter, string children);
}
或者是一个简单的DQL查询字符串
IEnumerable<T> QueryObjectGraph(Expression<Func<T, bool>> filter, string children);
IEnumerable查询对象图(表达式过滤器、字符串子项);
我不理解这另一个函数,children参数是什么/
Expression<Func<T, bool >>
编译器使用lambdas创建表达式。您提出的问题可以概括为。一旦你掌握了这个主题,你应该开始理解你所展示的代码
Func<>
Func
()是.NET中非常酷的一部分。它使我们能够写出更酷的作品!()
及
表达式
()是定义上述所有内容的一种方式,以便“以后解释”。最明显的例子是实体框架,它将在需要时将lambda表达式转换为SQL。这个问题与python有什么关系?将类转换为python可以帮助我,我不理解这种类型的暗示(表达式过滤器等,或者解释应该很好。)啊……我明白了……有意义
IEnumerable<T> QueryObjectGraph(Expression<Func<T, bool>> filter, string children);
Expression<Func<T, bool >>
x => x.Property > 5 && x.OtherProperty.Contains( "foo" )
Func<>
Expression<>