简体   繁体   English

用户生成的规范

[英]User's generated specifications

I want to let my users create specifications to be executed in a nhibernate.Linq query. 我想让我的用户创建要在nhibernate.Linq查询中执行的规范。

Is it possible? 可能吗? I ask the user to write a query string (HQL I suppose) so it will be serializable and in a combobox the user can apply it to current results 我要求用户编写一个查询字符串(我想是HQL),以便它可以序列化,并且在组合框中,用户可以将其应用于当前结果

Linq expressions are not serializable. Linq表达式不可序列化。

HQL, on the other hand, is just a string like SQL, so that would work. 另一方面,HQL只是像SQL这样的字符串,因此可以正常工作。

But you have to really trust your user, as there is nothing stopping him from typing "DELETE TheMostImportantEntity WHERE 1=1". 但是您必须真正信任您的用户,因为没有什么可以阻止他键入“ DELETE TheMostImportantEntity WHERE 1 = 1”。

另一种选择是使用LINQ动态查询库(请参见此处的详细信息: http : //weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq- dynamic-query-library.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM