Test:
1) entity class. This class does not use metadata matching, but uses special classes to store Map information, mainly for expression writing.
[Csharp]
Public class TestEntity
{
Private static readonly TableInfo _ TableInfo = new TableInfo () {TableName = "EEEE "};
Public static TableInfo
{
Get
{
Return _ TableInfo;
}
}
Private static readonly FieldInfo _ Id = new FieldInfo () {FieldName = "id "};
Public static FieldInfo Id
{
Get {return TestEntity. _ Id ;}
}
Private static readonly FieldInfo _ Name = new FieldInfo () {FieldName = "Name "};
Public static FieldInfo Name
{
Get {return TestEntity. _ Name ;}
}
}
2) test class
[Csharp]
Public class TestExp
{
Public static string Test ()
{
DbExpression theQuery = new DbExpression ();
TheQuery. Select (AliasExp. T1 [TestEntity. Id], AliasExp. T1 [TestEntity. Name])
. From (AliasExp. T1 [TestEntity. TableInfo])
. Where (AliasExp. T1 [TestEntity. Id]> ConstExp <int>. C ("Name", 100 ));
Return theQuery. Expression;
}
}
The expressions and parameters above www.2cto.com can be directly executed by Command. I only select the statements. In fact, the Update and Delete expressions are all available. Of course, if you continue to reload the operator, you can remove the constant expression and write it in the same way as normal, for example, A> 100, A = "100 ". the method of laziness is used here. Of course, it is still difficult to fully simulate it. Therefore, the expression also needs to retain the function of Directly Writing SQL statements and setting parameters.
The advantage of this expression is similar to that of SQL writing, but it is only applicable to entities and can maintain consistency. It can also use the smart prompt and syntax check functions of. The disadvantage is that it is not pure, and performance will also suffer.
Output results. You can run them on your own.
PS: The CSDN editor has some problems. It cannot be saved after a few minutes (less than 1 minute.
PS: It is expected that C # can support custom operation symbols to simulate a more pure expression.
From hawksoft