After reading what dragonpig wrote, "teach you 30 seconds to create a strong type of ASP. NET data binding", it was so powerful that we could still bind data like this.
I immediately tested it and made some improvements. It has been applied to the news section in home. Next, I will share my experiences on improvement.
Using the traditional ASP. NET data binding method, there are two aspects that have always been unpleasant:
1) Lack of smart sensing;
2) Forced type conversion.
Let's take a look at the traditional ASP. NET data binding:
Look at the top tostring (), (datetime )...
The idea of strong Type Binding of dragonpig already includes methods to solve these two problems,CodeSolved the first problem (SMART awareness), but ignored the second problem (forced type conversion). The original code is as follows:
Protected Virtual Object Exphelper < Tentity, tresult > (Func < Tentity, tresult > Func)
{
VaR ITM = Getdataitem ();
Return Func (tentity) ITM );
}
Protected Object Stu < Tresult > (Func < Student, tresult > Func)
{
Return Exphelper < Student, tresult > (Func );
}
During use, I found that forced type conversion was still required. It was a bit uncomfortable. After studying it, it turned out to be a curse of the object. As long as we changed the two objects in the above Code to tresult, the problem was solved.
In addition, I changed the stu method name to eval, which is more friendly.
Code:
Protected Virtual Tresult exphelper < Tentity, tresult > (Func < Tentity, tresult > Func)
{
VaR item = Base . Getdataitem ();
Return Func (tentity) item );
}
Protected Tresult eval < Tresult > (Func < Newsinfo, tresult > Func)
{
Return Exphelper < Newsinfo, tresult > (Func );
}
With "strong ASP. NET data binding", the days are wonderful...
Thank you, dragonpig! Your sharing is awesome!
After reading what dragonpig wrote, "teach you 30 seconds to create a strong type of ASP. NET data binding", it was so powerful that we could still bind data like this.
I immediately tested it and made some improvements. It has been applied to the news section in home. Next, I will share my experiences on improvement.
Using the traditional ASP. NET data binding method, there are two aspects that have always been unpleasant:
1) Lack of smart sensing;
2) Forced type conversion.
Let's take a look at the traditional ASP. NET data binding:
Look at the top tostring (), (datetime )...
The idea of strong Type Binding of dragonpig already includes methods to solve these two problems, but in the code displayed by dragonpig, it solves the first problem (SMART awareness ), however, the second problem is ignored (forced type conversion). The original code is as follows:
Protected Virtual Object Exphelper < Tentity, tresult > (Func < Tentity, tresult > Func)
{
VaR ITM = Getdataitem ();
Return Func (tentity) ITM );
}
Protected Object Stu < Tresult > (Func < Student, tresult > Func)
{
Return Exphelper < Student, tresult > (Func );
}
During use, I found that forced type conversion was still required. It was a bit uncomfortable. After studying it, it turned out to be a curse of the object. As long as we changed the two objects in the above Code to tresult, the problem was solved.
In addition, I changed the stu method name to eval, which is more friendly.
Code:
Protected Virtual Tresult exphelper < Tentity, tresult > (Func < Tentity, tresult > Func)
{
VaR item = Base . Getdataitem ();
Return Func (tentity) item );
}
Protected Tresult eval < Tresult > (Func < Newsinfo, tresult > Func)
{
Return Exphelper < Newsinfo, tresult > (Func );
}
With "strong ASP. NET data binding", the days are wonderful...
Thank you, dragonpig! Your sharing is awesome!