@ -24,45 +24,45 @@ Namespace Statements
' ' ' An object element in the target query collection . ( 目 标 待 查 询 集 合 之 中 的 一 个 元 素 )
' ' ' < / summary >
' ' ' < remarks > < / remarks >
Public Property [ Object ] As LINQ . Statements . Tokens . FromClosure
Public Property var As FromClosure
' ' ' < summary >
' ' ' Where test condition for the query . ( 查 询 所 使 用 的 Where 条 件 测 试 语 句 )
' ' ' Target query collection expression , this can be a file path or a database connection string .
' ' ' ( 目 标 待 查 询 集 合 , 值 可 以 为 一 个 文 件 路 径 或 者 数 据 库 连 接 字 符 串 )
' ' ' < / summary >
' ' ' < value > < / value >
' ' ' < returns > < / returns >
' ' ' < remarks > < / remarks >
Public Property ConditionTest As LINQ . Statements . Tokens . Where Closure
Public Property source As In Closure
' ' ' < summary >
' ' ' Target query collection expression , this can be a file path or a database connection string .
' ' ' ( 目标 待 查 询 集 合 , 值 可 以 为 一 个 文 件 路 径 或 者 数 据 库 连 接 字 符 串 )
' ' ' A read only object collection which were construct by the LET statement token in the LINQ statement .
' ' ' ( 使用 Let 语 句 所 构 造 出 来 的 只 读 对 象 类 型 的 对 象 申 明 集 合 )
' ' ' < / summary >
' ' ' < value > < / value >
' ' ' < returns > < / returns >
' ' ' < remarks > < / remarks >
Public Property Collection As LINQ . Statements . Tokens . InClosure
Public Property PreDeclare As LetClosure ( )
' ' ' < summary >
' ' ' A read only object collection which were construct by the LET statement token in the LINQ statement .
' ' ' ( 使 用 Let 语 句 所 构 造 出 来 的 只 读 对 象 类 型 的 对 象 申 明 集 合 )
' ' ' Where test condition for the query . ( 查 询 所 使 用 的 Where 条 件 测 试 语 句 )
' ' ' < / summary >
' ' ' < value > < / value >
' ' ' < returns > < / returns >
' ' ' < remarks > < / remarks >
Public Property ReadOnlyObjects As LINQ . Statements . Tokens . LetClosure ( )
Public Property Where As WhereClosure
Public Property AfterDeclare As LetClosure ( )
' ' ' < summary >
' ' ' A expression for return the query result . ( 用 于 生 成 查 询 数 据 返 回 的 语 句 )
' ' ' < / summary >
' ' ' < value > < / value >
' ' ' < returns > < / returns >
' ' ' < remarks > < / remarks >
Public Property SelectC onstruct As LINQ . Statements . Tokens . SelectClosure
Public Property SelectC losure As SelectClosure
Friend _Tokens As String ( )
Friend TypeRegistry As LINQ . Framework . TypeRegistry
Friend TypeRegistry As TypeRegistry
' ' ' < summary >
' ' ' 本 LINQ 脚 本 对 象 所 编 译 出 来 的 临 时 模 块
' ' ' < / summary >
' ' ' < remarks > < / remarks >
Friend ILINQProgram As System. Type
Friend ILINQProgram As Type
Public ReadOnly Property CompiledCode As String
@ -75,17 +75,21 @@ Namespace Statements
' ' ' < remarks > < / remarks >
Public ReadOnly Property TypeId As String
Get
Return [ Object ] . TypeId
Return var . TypeId
End Get
End Property
Public ReadOnly Property IsParallel As Boolean
Get
Return Me . Collection . IsParallel
Return Me . source . IsParallel
End Get
End Property
Public ReadOnly Property Original As String
' ' ' < summary >
' ' ' Original statement text of this linq expression
' ' ' < / summary >
' ' ' < returns > < / returns >
Public ReadOnly Property Text As String
' ' ' < summary >
' ' ' Create a instance for the compiled LINQ statement object model .
@ -97,53 +101,55 @@ Namespace Statements
End Function
Public Overrides Function ToString ( ) As String
Return Original
Return Text
End Function
' ' ' < summary >
' ' ' Try to parsing a linq query script into a statement object model and compile the model into a assembly dynamic .
' ' ' ( 尝 试 着 从 所 输 入 的 命 令 语 句 中 解 析 出 一 个 LINQ 查 询 命 令 对 象 , 并 完 成 动 态 编 译 过 程 )
' ' ' < / summary >
' ' ' < param name = " StatementText " > < / param >
' ' ' < param name = " source " > < / param >
' ' ' < returns > < / returns >
' ' ' < remarks > < / remarks >
Public Shared Function TryParse ( StatementText As String , registry As TypeRegistry ) As LINQStatement
Dim Statement As LINQStatement = New LINQStatement With {
. _Original = StatementText ,
. _Tokens = GetTokens ( StatementText ) ,
. TypeRegistry = registry
Public Shared Function TryParse ( source As String ) As LINQStatement
Dim tokens As ClosureTokens ( ) = ClosureParser . TryParse ( source )
Dim statement As LINQStatement = New LINQStatement With {
. _Text = source
}
Statement . Collection = New InClosure ( Statement )
Statement . Object = New FromClosure ( Statement )
Statement . ReadOnlyObjects = GetReadOnlyObjects ( Statement )
Statement . ConditionTest = New WhereClosure ( Statement )
Statement . SelectConstruct = New SelectClosure ( Statement )
Using Compiler As DynamicCompiler = New DynamicCompiler ( Statement , SDK_PATH . AvaliableSDK ) ' Dynamic code compiling . ( 动 态 编 译 代 码 )
Dim LINQEntityLibFile As String = Statement . Object . RegistryType . AssemblyFullPath '
If Not String . Equals ( FileIO . FileSystem . GetParentPath ( LINQEntityLibFile ) , System . Windows . Forms . Application . StartupPath ) Then
LINQEntityLibFile = String . Format ( " {0}\TEMP_LINQ.Entity.lib " , System . Windows . Forms . Application . StartupPath )
If FileIO . FileSystem . FileExists ( LINQEntityLibFile ) Then
Call FileIO . FileSystem . DeleteFile ( LINQEntityLibFile , FileIO . UIOption . OnlyErrorDialogs , FileIO . RecycleOption . SendToRecycleBin )
End If
Call FileIO . FileSystem . CopyFile ( Statement . Object . RegistryType . AssemblyFullPath , LINQEntityLibFile )
End If
Dim ReferenceAssemblys As String ( ) = New String ( ) { LQueryFramework . ReferenceAssembly , LINQEntityLibFile }
Dim CompiledAssembly = Compiler . Compile ( ReferenceAssemblys )
Statement . ILINQProgram = DynamicInvoke . GetType ( CompiledAssembly , Framework . DynamicCode . VBC . DynamicCompiler . ModuleName ) . First
Statement . _CompiledCode = Compiler . CompiledCode
End Using
Return Statement . Initialzie
statement . var = New FromClosure ( tokens , statement )
statement . source = New InClosure ( tokens , statement )
statement . PreDeclare = Parser . GetPreDeclare ( tokens , statement )
statement . Where = New WhereClosure ( tokens , statement )
statement . AfterDeclare = Parser . GetAfterDeclare ( tokens , statement )
statement . SelectClosure = New SelectClosure ( tokens , statement )
Return statement
' Using Compiler As DynamicCompiler = New DynamicCompiler ( Statement , SDK_PATH . AvaliableSDK ) ' Dynamic code compiling . ( 动 态 编 译 代 码 )
' Dim LINQEntityLibFile As String = Statement . Object . RegistryType . AssemblyFullPath '
' If Not String . Equals ( FileIO . FileSystem . GetParentPath ( LINQEntityLibFile ) , System . Windows . Forms . Application . StartupPath ) Then
' LINQEntityLibFile = String . Format ( " {0}\TEMP_LINQ.Entity.lib " , System . Windows . Forms . Application . StartupPath )
' If FileIO . FileSystem . FileExists ( LINQEntityLibFile ) Then
' Call FileIO . FileSystem . DeleteFile ( LINQEntityLibFile , FileIO . UIOption . OnlyErrorDialogs , FileIO . RecycleOption . SendToRecycleBin )
' End If
' Call FileIO . FileSystem . CopyFile ( Statement . Object . RegistryType . AssemblyFullPath , LINQEntityLibFile )
' End If
' Dim ReferenceAssemblys As String ( ) = New String ( ) { LQueryFramework . ReferenceAssembly , LINQEntityLibFile }
' Dim CompiledAssembly = Compiler . Compile ( ReferenceAssemblys )
' Statement . ILINQProgram = DynamicInvoke . GetType ( CompiledAssembly , Framework . DynamicCode . VBC . DynamicCompiler . ModuleName ) . First
' Statement . _CompiledCode = Compiler . CompiledCode
' End Using
' Return Statement . Initialzie
End Function
Private Function Initialzie ( ) As LINQStatement
Call [ Object ] . Initialize ( )
Call ConditionTest . Initialize ( )
Call SelectC onstruct . Initialzie ( )
Call var . Initialize ( )
Call Where . Initialize ( )
Call SelectC losure . Initialzie ( )
Return Me
End Function
End Class