我试图调用存储过程using Dapper.Net并获取返回值.
p.Add("@INCIDENT_ID", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
var retResults = con.Execute("usp_GetIncidentID", p, commandType:CommandType.StoredProcedure);
int IncidentID = p.Get<int>("INCIDENT_ID");
Run Code Online (Sandbox Code Playgroud)
我已经尝试了几个与参数方向不同的东西并使用了"@INCIDENT_ID".如果您单步执行结果,您可以看到值中存在正确的返回值retResults,但我无法按照下面的文档中描述的方式访问这些值.
存储过程Dapper支持完全存储的过程:
var user = cnn.Query<User>("spGetUser", new {Id = 1},
commandType: CommandType.StoredProcedure).First();}}}
If you want something more fancy, you can do:
var p = new DynamicParameters();
p.Add("@a", 11);
p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output);
p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
cnn.Execute("spMagicProc", p, commandType: commandType.StoredProcedure);
int b = p.Get<int>("@b");
int c = p.Get<int>("@c");
Run Code Online (Sandbox Code Playgroud) 我到处寻找可以找到解决方案.我发现的唯一一件事是没有回复的帖子.如果我忽略了某些事情,我会道歉.
问题是,当我尝试获取API中的POST值时/createQuestion,正文是空的/未定义的.我Cannot read proprety 'question' of undefined从API 那里得到这样的错误.
Express API:
app.post("/createQuestion", function(req, res) {
var questionType = req.body.question.type;
var questionText = req.body.question.text;
var questionDuringClass = req.body.question.duringClass;
// Do a bunch of stuff
res.send(response);
});
Run Code Online (Sandbox Code Playgroud)
考试:
var should = require('should');
var assert = require('assert');
var request = require('supertest');
var winston = require('winston');
request = request('http://localhost:8080');
describe('Questions', function() { // Test suite
before(function(done) {
done();
});
it('Should create a freeResponse question', function(done) { // Test case …Run Code Online (Sandbox Code Playgroud) 我正在尝试在USB闪存上创建一个带有FatFs的文件,但是我的f_open调用尝试读取第一次文件系统挂载的启动扇区时挂起了这个函数.
DRESULT disk_read (
BYTE drv, /* Physical drive number (0) */
BYTE *buff, /* Pointer to the data buffer to store read data */
DWORD sector, /* Start sector number (LBA) */
BYTE count /* Sector count (1..255) */
)
{
BYTE status = USBH_MSC_OK;
if (drv || !count) return RES_PARERR;
if (Stat & STA_NOINIT) return RES_NOTRDY;
if(HCD_IsDeviceConnected(&USB_OTG_Core))
{
do
{
status = USBH_MSC_Read10(&USB_OTG_Core, buff,sector,512 * count);
USBH_MSC_HandleBOTXfer(&USB_OTG_Core ,&USB_Host);
if(!HCD_IsDeviceConnected(&USB_OTG_Core))
{
return RES_ERROR;
}
}
while(status == …Run Code Online (Sandbox Code Playgroud) 我正在编写一个用于在ASP.NET 5应用程序中管理用户的UI .我需要在UI中显示UserManager返回的任何错误.我IdentityResult在视图模型中传递了错误,但在测试我的代码时我是一个漂亮的触摸器.
什么是嘲笑的最佳方法UserManager的ASP.NET 5?
我应该继承UserManager并覆盖我正在使用的所有方法,然后将我的版本注入我的测试项目UserManager的实例中Controller吗?
"ATL简单对象"向导未提供指定从现有coclass及其接口派生新类的方法.在Visual Studio 2008中,如何创建一个从现有的ATL COM类派生的新类(即Base实现IBase,我想创建一个Derived派生自Base该实现的新类IDerived,其中IDerived派生自IBase.)
更新:听起来很简单,但向导生成的ATL类最多有六个基类,一个COM映射和一个连接点映射.应该在派生类中重复哪些基类和映射?如果映射在派生类中重复,它们是否应包含基类映射的内容或仅包含其他项?基类的顺序是否重要?怎么样FinalConstruct()和FinalRelease()?应该DECLARE_PROTECT_FINAL_CONSTRUCT和DECLARE_REGISTRY_RESOURCEID在派生类中被重复?
这是一个示例基类,除了所有样板文件外都是空的.现在派生类应该是什么样的?
class ATL_NO_VTABLE CBase :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CBase, &CLSID_Base>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CBase>,
public CProxy_IBaseEvents<CBase>,
public IDispatchImpl<IBase, &IID_IBase, &LIBID_ExampleLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
CBase()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_Base)
BEGIN_COM_MAP(CBase)
COM_INTERFACE_ENTRY(IBase)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CBase)
CONNECTION_POINT_ENTRY(__uuidof(_IBaseEvents))
END_CONNECTION_POINT_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void …Run Code Online (Sandbox Code Playgroud) 我有一节课,PlayerInputComponent:
.H:
class PlayerInputComponent
{
public:
PlayerInputComponent(PlayerMoveComponent& parentMoveComponent_, std::unique_ptr<IRawInputConverter> inputConverter_);
PlayerInputComponent(PlayerInputComponent&& moveFrom);
void update();
private:
std::unique_ptr<IRawInputConverter> inputConverter;
PlayerMoveComponent& parentMoveComponent;
};
}
Run Code Online (Sandbox Code Playgroud)
的.cpp:
PlayerInputComponent::PlayerInputComponent(PlayerMoveComponent& parentMoveComponent_, std::unique_ptr<IRawInputConverter> inputConverter_) :
parentMoveComponent(parentMoveComponent_),
inputConverter(std::move(inputConverter_))
{
}
PlayerInputComponent::PlayerInputComponent(PlayerInputComponent&& moveFrom) :
parentMoveComponent(moveFrom.parentMoveComponent),
inputConverter(moveFrom.inputConverter.release())
{
}
Run Code Online (Sandbox Code Playgroud)
和一个PlayerMoveComponen包含PlayerInputComponent成员的类,并使用std::unique_ptr传递作为参数对其进行初始化.它的构造函数:
PlayerMoveComponent::PlayerMoveComponent(/* other parameters */ std::unique_ptr<IRawInputConverter> inputConverter) :
//other initializations
inputComponent(PlayerInputComponent(*this, std::move(inputConverter)))
{
}
Run Code Online (Sandbox Code Playgroud)
我为PlayerInputComponent类定义了自己的移动构造函数,因为我的理解是不会为包含引用成员的类构造默认移动构造函数.在这种情况下,虽然我知道引用将保留在PlayerInputComponent对象生命周期的持续时间内.
由于我初始化PlayerMoveComponent的inputComponent从一个临时变量,笔者认为以下两件事情之一是应该发生的:
PlayerInputComponent的移动构造函数用于初始化playerInputComponent成员变量.但是,Visual Studio 2012吐出了这个:
error C2248: …Run Code Online (Sandbox Code Playgroud) 在boost::interprocess文档中,据说要将容器存储在共享内存中:
operator==()在运行时进行测试.allocator::pointer,容器可能不会假定allocator::pointer是原始指针.allocator::construct和allocator::destroy函数构造所有对象.我正在使用gcc 4.7.1和-std = c ++ 11(和boost 1.53).使用下面定义的ShmVector类型是否安全?
typedef boost::interprocess::allocator<int,
boost::interprocess::managed_shared_memory::segment_manager> ShmemAllocator;
typedef std::vector<int, ShmemAllocator> ShmVector;
Run Code Online (Sandbox Code Playgroud)
我尝试了一个使用这种类型的虚拟进程,看起来它正在工作,但我仍然不确定gcc4.7.1中的向量是否满足所有要求.我对第一个要求特别不确定.
#include <iostream>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <vector>
#include <cstdlib> //std::system
typedef boost::interprocess::allocator<int,
boost::interprocess::managed_shared_memory::segment_manager> ShmemAllocator;
typedef std::vector<int, ShmemAllocator> ShmVector;
int main(int argc, char *argv[])
{
if(argc == 1){ //Parent process
struct shm_remove
{
shm_remove() { boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
~shm_remove(){ boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
} remover;
//Create a new …Run Code Online (Sandbox Code Playgroud) 我想TSaveDialog在Delphi XE6中使用a :
if not SaveDialog1.Execute(0) then
Exit;
Run Code Online (Sandbox Code Playgroud)
该调用立即返回false,而不显示任何对话框.我将其追溯到创建shell Save Dialog COM对象的行为:
function TCustomFileSaveDialog.CreateFileDialog: IFileDialog;
var
LGuid: TGUID;
begin
LGuid := CLSID_FileSaveDialog;
CoCreateInstance(LGuid, nil, CLSCTX_INPROC_SERVER,
StringToGUID(SID_IFileSaveDialog), Result);
end;
Run Code Online (Sandbox Code Playgroud)
呼叫CoCreateInstance失败了.我创建了最少的代码来重现问题:
procedure TForm1.Button1Click(Sender: TObject);
const
CLSID_FileSaveDialog: TGUID = '{C0B4E2F3-BA21-4773-8DBA-335EC946EB8B}';
begin
CreateComObject(CLSID_FileSaveDialog);
end;
Run Code Online (Sandbox Code Playgroud)
它抛出EOleSysError异常:
0x80040111:ClassFactory无法提供请求的类,ClassID:{C0B4E2F3-BA21-4773-8DBA-335EC946EB8B}
我的应用程序是使用公共控件库(6.0.7601.18837)的第6版,但我意识到,如果用户已禁用我的应用程序的视觉样式时才会发生:
我们仍在使用公共控件库的第6版,只IsAppThemed返回false.
注意:我知道很多人错误地认为:
- Visual Styles API仅在我们加载了Comctrl32.dll版本6时才有效
- 如果加载了Comctrl32.dll的版本6,则Visual Styles API将起作用
- 如果我们不使用ComCtrl v6那么这意味着视觉样式被禁用
- 如果我们使用旧的公共控件库,则禁用视觉样式
蛮力解决方案是将全局UseLatestCommonDialogs设置为false.
但这非常糟糕,因为它仅适用于在应用程序中禁用视觉样式的人:
这意味着我不能简单地使用IsAppThemed,因为如果 …
在阅读关于集合实现的Oracle教程时,我发现了以下句子:
如果您需要同步,则a
Vector将比ArrayList同步的稍快Collections.synchronizedList
来源:列表实现
但是当搜索它们之间的差异时,许多人不鼓励使用,Vector并且应该在SynchronizedList需要同步时替换.那么哪一方有权被追随?
c++ ×4
c# ×2
asp.net-core ×1
atl ×1
c ×1
c++11 ×1
classwizard ×1
collections ×1
com ×1
dapper ×1
delphi ×1
delphi-xe6 ×1
embedded ×1
express ×1
fatfs ×1
gcc4.7 ×1
java ×1
list ×1
mocha.js ×1
node.js ×1
qt ×1
rest ×1
sql-server ×1
stm32 ×1
supertest ×1
themes ×1
unit-testing ×1
usb-otg ×1
vector ×1
xunit.net ×1