我如何构建并保存到数据库供以后使用半任意lambda表达式? [英] How can I construct and save to a DB for later use a semi-arbitrary lambda expression?

查看:141
本文介绍了我如何构建并保存到数据库供以后使用半任意lambda表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个报告引擎。我的一个在试图挑战使它更通用正试图找出如何让用户在其查询更多的灵活性,这意味着生成自己以备后用,而不是使用我提供一组固定的。

I'm creating a reporting engine. One of my challenges in trying to make it more generic is trying to figure out how to give users more flexibility in their queries, meaning generate their own for later use rather than using a fixed set provided by me.

例如,说我有有有N线的对象ñ部分对象的文档对象。

For example, say I have a Document object which has N Section objects which has N Line objects.

在代码比较静态的目标,我可以轻松地获得文档的列表那里是具有有使用文档的列表和lambda表达式在where子句中包含一些文本值的行的部分。

In code with more static goals, I can easily get a list of Documents where there is a Section that has a Line which has a value containing some text using a where clause on a list of Documents and a lambda expression.

然而,也有很多(几乎无限的)可能的表达式,因此限制了人的子集或者具有以编码每一个可能的路径作为一个参数化的方法,没有确实可行的。

However, there are a lot (almost infinite) possible expressions, so limiting people to a subset or having to encode every possible path as a parametrized method is not really viable.

所以,问题是,我如何1)构造从字符串数据的lambda表达式(意思是我如何能有效地发送到服务器的一些数据,我可以灵活转换的表达式),2)我怎么能保存的表达在一个数据库以后使用?

So the question is, how do I 1) Construct a lambda expression from string data (meaning how can I effectively POST to the server some data which I can flexibly convert to the expression) and 2) how can I save that expression for later use in a DB?

大概只有#1是真的重要,因为如果我可以构造表达式时POST数据,我可以存储字符串信息到数据库和做同样的过程,但我现在不知道如何完成#1

Probably only #1 is really relevant since if I can construct the expression when POST data that I can store that string info to the DB and do the same process, but I currently have no idea how to accomplish #1

有什么建议?我觉得这在理论上是可行的事情,但我显然缺少的基本方法。

Any suggestions? I feel like this is a workable thing in theory but I'm clearly missing the basic approach.

推荐答案

不知道这是否会帮助你或没有,但这里有几个建议:

Not sure if this will help you or not, but here are a couple suggestions:


  1. 使用谓词生成器考虑。 下面是关于这种方法的更多信息。

您可能能够使用动态LINQ,你可以在DB,保存查询,以备以后使用,就像普通的字符串。我有这种方法没有任何经验,但你可以阅读起来就可以了这里如果你感兴趣。

You might be able to use dynamic linq, and you could save the queries in the DB for later use, just as regular strings. I have no experience with this approach, but you can read up on it here if you're interested.

与发动机祝你好运,听起来很有趣!

Good luck with the engine, sounds interesting!

这篇关于我如何构建并保存到数据库供以后使用半任意lambda表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆