I am calling:
form = new FormFor<Project>()
.Set(x => x.Name, "hi");
where Project has a field called Name and FormFor's code is:
public class FormFor<TEntity> where TEntity : class
{
FormCollection form;
public FormFor()
{
form = new FormCollection();
}
public FormFor<TEntity> Set(Expression<Func<TEntity>> property, string value)
{
form.Add(property.PropertyName(), value);
return this;
}
}
but it keeps telling me Delegate 'System.Func<ProjectSupport.Core.Domain.Project>' does not take 1 arguments
and I am unsure why. Could anyone shed some light on it for me?
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
It's trying to convert this lambda expression:
x => x.Name
into an Expression<Func<TEntity>>
.
Let's ignore the expression tree bit for the moment - the delegate type Func<TEntity>
represents a delegate which takes no arguments, and returns a TEntity
. Your lambda expression x => x.Name
clearly is expecting a parameter (x
). I suspect you want
Expression<Func<TEntity, string>>
or something similar, but it's not really clear what you're trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With