小编Alt*_*oru的帖子

StringTemplate - 如何遍历业务对象列表并输出简单的html?

我刚开始在C#项目中使用StringTemplate.我浏览了文档,但似乎无法找到实现这个简单场景的方法:

我有一个简单的业务对象列表(让我们说订单),我希望它们显示在我的html模板中的UL标签内.

所以,我的.st模板看起来像这样(伪代码):

<html> some text <ul>[Order template]<li>[Order name here]</li>[/Order template]</ul></html>

我希望我的输出是:

<html> some text <ul><li>Order 1</li><li>Order 2</li>...</ul></html>

我无法弄清楚如何使用StringTemplate来完成这项工作.有任何想法吗?

c# stringtemplate

11
推荐指数
1
解决办法
6516
查看次数

JSON.NET C#中的反序列化导致空对象

我正在尝试使用JSON.NET反序列化来填充C#对象(ImportedProductCodesContainer)和数据.

ImportedProductCodesContainer.cs:

using Newtonsoft.Json;

[JsonObject(MemberSerialization.OptOut)]
public class ImportedProductCodesContainer
{
    public ImportedProductCodesContainer()
    {

    }

    [JsonProperty]
    public ActionType Action { get; set; }

    [JsonProperty]
    public string ProductListRaw { get; set; }


    public enum ActionType {Append=1, Replace};
}
Run Code Online (Sandbox Code Playgroud)

JSON字符串:

{"ImportedProductCodesContainer":{"ProductListRaw":"1 23","Action":"Append"}}
Run Code Online (Sandbox Code Playgroud)

C#代码:

 var serializer = new JsonSerializer();
 var importedProductCodesContainer = 
     JsonConvert.DeserializeObject<ImportedProductCodesContainer>(argument);
Run Code Online (Sandbox Code Playgroud)

的问题是,importedProductCodesContainer保持运行上面的代码后空的(动作= 0,ProductListRaw = NULL).你能帮我弄清楚出了什么问题吗?

c# json.net

6
推荐指数
1
解决办法
4775
查看次数

剃刀 - 输出单引号

在.NET 4.5/MVC 5.1.2项目中,我尝试使用此Razor语法在JavaScript标记内写入:

@string.Join(",", ((IEnumerable<JqGridColumn>)ViewBag.JqGridColumns)
    .Select(p => Html.Raw("'" + p.Name + "'")))
Run Code Online (Sandbox Code Playgroud)

预期产量:

'Col 1', 'Col 2', 'Col 3', ...
Run Code Online (Sandbox Code Playgroud)

实际产量:

&#39;Col 1&#39;,&#39;Col 2&#39;,&#39;Col 3&#39;, ...
Run Code Online (Sandbox Code Playgroud)

如何使用上面的Razor语法输出单引号字符?

asp.net-mvc razor

3
推荐指数
1
解决办法
1148
查看次数

SQL Server 2005触发器-如何安全地确定是由UPDATE还是DELETE触发?

我在SQL Server 2005触发器中有以下代码:

在[myTable]上创建触发器[myTrigger]
更新,删除
如
开始

宣告@OperationType VARCHAR(6)
如果存在(从插入中选择1个)
开始
    SET @ OperationType ='更新'
结束
其他
开始
    SET @ OperationType ='删除'
结束

我的问题:@OperationType是否存在未正确填充的情况?EG:表中的数据由一堆UPDATE / DELETE语句更改,但是触发器不是每个触发器都触发一次吗?

您是否有更好的方法来确定触发器是由UPDATE还是DELETE语句触发的?

database triggers sql-server-2005

1
推荐指数
1
解决办法
3534
查看次数