我试图获取Case_Id的列表,其中案例不包含使用Microsoft Sql Server 2012的特定RoleId.
例如,我想获得一个不包含RoleId为4的Case_Id集合.
因此,从查询下面的数据集中将排除Case_Id的49,50和53.
Id RoleId Person_Id Case_Id
--------------------------------------
108 4 108 49
109 1 109 49
110 4 110 50
111 1 111 50
112 1 112 51
113 2 113 52
114 1 114 52
115 7 115 53
116 4 116 53
117 3 117 53
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已尝试过以下内容
SELECT Case_Id
FROM [dbo].[caseRole] cr
WHERE cr.RoleId!=4
GROUP BY Case_Id ORDER BY Case_Id
Run Code Online (Sandbox Code Playgroud) 我在选择框的选定值绑定到视图模型中的属性时遇到问题.由于某种原因,它在回发到服务器时保持不变.
我的Html是:
<form action="/Task/Create" data-bind="submit: save">
<table border="1">
<tr>
<td>ref type</td>
<td><select data-bind="options: ReferenceTypes, optionsText: 'Name', optionsCaption: 'Select...', value:Task.ReferenceTypeId"></select></td>
<td>Reference</td>
<td><input data-bind="value:Task.Reference" /></td>
</tr>
</table>
<button type="submit">Save Listings</button>
</form>
Run Code Online (Sandbox Code Playgroud)
Javascript是:
<script type="text/javascript">
var viewModel = {};
$.getJSON('/Task/CreateJson', function (result) {
viewModel = ko.mapping.fromJS(result.Data);
viewModel.save = function () {
var data = ko.toJSON(this);
$.ajax({
url: '/Task/Create',
contentType: 'application/json',
type: "POST",
data: data,
dataType: 'json',
success: function (result) {
ko.mapping.updateFromJS(viewModel, result);
}
});
}
ko.applyBindings(viewModel);
});
</script>
Run Code Online (Sandbox Code Playgroud)
来自Fiddler的JSON,如下所示加载到页面中.
{
"ContentEncoding":null,
"ContentType":null,
"Data":{ …Run Code Online (Sandbox Code Playgroud) 我问如何基于文档上的两个不同的嵌套属性创建索引.我正在通过C#执行这些查询.
public class LocationCode
{
public string Code {get;set;}
public string SeqId {get;set;}
}
public class ColorCode
{
public string Code {get;set;}
public string SeqId {get;set;}
}
public class TestDocument
{
public int Id {get;set;}
public List<LocationCode> Locations { get; set; }
public List<ColorCode> Colors { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了各种AbstractIndexCreationTask,Map和Map + Reduce,但无济于事.
我希望能够进行如下查询:
获取所有Locations.Code属性为"USA",AND/OR Colors.Code ="RED"或SeqId属性的文档.我不知道这是否意味着我需要多个索引.通常我会比较嵌套类或Seq上的Code属性,但从不混合.
请有人指出我正确的方向.
非常感谢Phil
我希望生成一个必须采用以下格式的随机字符串:
[LETTER] [NUMBER] [LETTER] [NUMBER]等等到特定长度
到目前为止,我有一个随机的字符串生成器,删除我不想要的几个字符,任何关于如何实现这样的字符串的建议将不胜感激.
public static string GenerateRandomString(int length)
{
const string chars = "ABCEFGHJKPQRSTXYZ23456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s =>s[RandomHelper.StaticRandom.Instance.Next(s.Length)])
.ToArray());
}
Run Code Online (Sandbox Code Playgroud)