我需要在数据库表订购结果ChargeOperations在我自己的方向通过typeId.SQL请求是这样的:
SELECT * FROM ChargeOperations co
LEFT JOIN ShadowChargeOperations sco ON sco.ChargeOperationId=co.Id
-- just exclude some extra data.
WHERE sco.Id IS NULL
ORDER BY
CASE co.TypeId
WHEN 1 THEN 3 -- this is my order, which is different from id of type and can change
WHEN 2 THEN 1
WHEN 3 THEN 2
ELSE 4
END,
co.TypeId,
co.CalculationAmount
Run Code Online (Sandbox Code Playgroud)
那么,请你给我一个例子,说明如何创建这种结构.
CASE co.TypeId
WHEN 1 THEN 3 -- this is my order, which is different from …Run Code Online (Sandbox Code Playgroud) 如何从 Windows 8-10 上的代码打印 pdf 文档?我得到下一个例外:Additional information: The specified executable is not a valid application for this OS platform.
当我制作 proc.Start() 时。这是因为我尝试调用的不是 exe,而是 pdf 文件。
这种方法适用于 Windows 7。在较新的版本上它不起作用。
private void SendToPrinter()
{
var proc = new Process
{
string fileName = "c:\output.pdf"
StartInfo = new ProcessStartInfo
{
Verb = "printto",
FileName = fileName,
Arguments = "\"" + printerName + "\"",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
RedirectStandardOutput = true,
UseShellExecute = false
}
};
proc.Start();
proc.WaitForInputIdle();
Thread.Sleep(3000);
if (!proc.HasExited …Run Code Online (Sandbox Code Playgroud) 我想创建一个通用堆栈
我有一个Node类
public class GenericNode<T> where T : class
{
public T item;
public GenericNode<T> next;
public GenericNode()
{
}
public GenericNode(T item)
{
this.item = item;
}
}
Run Code Online (Sandbox Code Playgroud)
并且可以使用它
GenericNode<string> node = new GenericNode<string>("one")
Run Code Online (Sandbox Code Playgroud)
但我不能用它也喜欢
GenericNode<int> node = new GenericNode<int>(1)
Run Code Online (Sandbox Code Playgroud)
因为int不是引用类型(不是类)而我使用的地方是T:class但是List也不是引用类型.
我该如何解决我的问题?
我和Daniel在这个主题中有同样的问题,但他的解决方案对我不起作用:
用例.用户一个接一个地添加2个新记录:
用户在网格中看到一条记录
再次按"添加新记录"按钮
记录一个准备好了.按"保存".数据转到控制器而不是数据库.在这一刻发生了一些事情,网格再次向控制器发送记录一个数据的Ajax请求.
用户更新网格并查看三条记录
"Alex | 10 | first"(重复记录)ID = 1
"Bob | 20 | second"ID = 2
"Alex | 10 | first"ID = 1
他们建议返回一个ID,以便用新记录正确绑定\更新数据源.我返回它(来自数据库的新ID与bouns实体一起响应)!这没有用.只有当我用F5添加第一个记录和刷新页面之后再添加第二个记录一切正常.但如果添加另一个,第三个记录 - 问题再次出现
控制器中的代码:
[HttpPost]
public JsonResult Create(BonusDto bonusDto)
{
BonusAggregate bonus;
if (bonusDto.Amount <= 0)
throw new ArgumentOutOfRangeException("Amount should be more than 0");
if (bonusDto.EmployeeId <= 0)
throw new ArgumentNullException("You should specify an existing employee");
using (var dbContext = …Run Code Online (Sandbox Code Playgroud) Asp.net core 3.1 WebApi。
我有一个具有所需属性的模型。
1.如果模型无效,则响应包含如下数据:
{
"errors": {
"Name": [
"Update model can't have all properties as null."
],
"Color": [
"Update model can't have all properties as null."
]
},
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "|f032f1c9-4c36d1e62aa60ead."
}
Run Code Online (Sandbox Code Playgroud)
这对我来说看起来不错。
但是,如果我向 modelState.AddModelError("statusId", "Invalid order status id.") 添加一些自定义验证,那么它会返回不同的结构:
[
{
"childNodes": null,
"children": null,
"key": "statusId",
"subKey": {
"buffer": "statusId",
"offset": 0,
"length": 8,
"value": "statusId",
"hasValue": true
},
"isContainerNode": false,
"rawValue": "11202",
"attemptedValue": …Run Code Online (Sandbox Code Playgroud) validation asp.net-mvc modelstate asp.net-web-api asp.net-core
c# ×2
.net ×1
asp.net-core ×1
asp.net-mvc ×1
case ×1
class ×1
command-line ×1
duplicates ×1
generics ×1
hibernate ×1
int ×1
json ×1
kendo-grid ×1
kendo-ui ×1
modelstate ×1
nhibernate ×1
pdf ×1
printing ×1
queryover ×1
reference ×1
sql-order-by ×1
validation ×1