开发者

Java LINQ -like functionality [duplicate]

开发者 https://www.devze.com 2023-04-12 03:14 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: LINQ for Java tool In C# there is a capability to use LINQ statements in order to access a Collection as if
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

LINQ for Java tool

In C# there is a capability to use LINQ statements in order to access a Collection as if writing a SQL statement. I would like to create a similar plug-in for Java and was wondering you gu开发者_Python百科ys had any advice for how to go about doing this? I would like to make it as similar to SQL as possible.


Well this is quite difficult to do in java since LINQ is built and integrated into the C# language. If I were to do this, I would probably create a class for all actions in MySQL: for example "Select", "Join"... and then make methods for actions you would like to conduct on them. Select(...).From where "From" is a method on the Select class. This is a very simplified example of course, but what you need to do is create a SQL compiler in Java, and then add any custom methods or classes you would want.

A word of caution however, LINQ is more efficient than writing loops in C#, however if you were to write your own custom Java LINQ, you would simply be writing shortcuts. What I am trying to say is that, you will not be making your code any more efficient, simply more readable and compact.

0

精彩评论

暂无评论...
验证码 换一张
取 消