是否可以像这样做一个OR语句?
WHERE pR.projectRelationId = '$id[ 0 ]' OR '$id[ 1 ]' OR '$id[ 2 ]'
AND pR.type = 'yada' AND
Run Code Online (Sandbox Code Playgroud)
或者您是否必须继续重新进行比较:
WHERE
pR.projectRelationId = '$id[ 0 ]' OR
pR.projectRelationId = '$id[ 1 ]' OR
pR.projectRelationId = '$id[ 2 ]'
AND
pR.type = 'yada' AND
Run Code Online (Sandbox Code Playgroud) 我有一个功能:
public void Callback()
{
// Does some stuff
}
Run Code Online (Sandbox Code Playgroud)
我想将它传递给另一个函数,然后将其传递给另一个函数,然后执行函数...到目前为止我有这个:
public void StartApp() // entry point
{
StartMyAwesomeAsyncPostRequest( Callback );
}
public void StartMyAwesomeAsyncPostRequest( Delegate callback )
{
// Work out some stuff and start a post request
TheActualAsyncPostRequest( callback );
}
public void TheActualAsyncPostRequest( Delegate callback )
{
// Do some jazz then run the delegated function
callback();
}
Run Code Online (Sandbox Code Playgroud)
我看了几个其他的例子,但是来自PHP和javascript背景,我正在努力解释,你能不能给我一个特定于我的请求的例子或解释?提前致谢!
我创建了一个post请求类,我可以重用它来向外部api发出POST请求并返回它们发送给我的对象(JSON):
class PostRequest
{
private Action<DataUpdateState> Callback;
public PostRequest(string urlPath, string data, Action<DataUpdateState> callback)
{
Callback = callback;
// form the URI
UriBuilder fullUri = new UriBuilder(urlPath);
fullUri.Query = data;
// initialize a new WebRequest
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUri.Uri);
request.Method = "POST";
// set up the state object for the async request
DataUpdateState dataState = new DataUpdateState();
dataState.AsyncRequest = request;
// start the asynchronous request
request.BeginGetResponse(new AsyncCallback(HandleResponse),
dataState);
}
private void HandleResponse(IAsyncResult asyncResult)
{
// get the state information
DataUpdateState …Run Code Online (Sandbox Code Playgroud) 因为对API的Post请求需要在Windows Phone上异步运行,所以我很难创建一个易于使用的精简库来与API进行交互.
问题是使用库的人总是需要提供回调函数.
我们来看看一些伪代码:
PostRequest类帮助我处理POST请求:
class PostRequest
{
private Action<MemoryStream> Callback;
public PostRequest(string urlPath, string data, Action<MemoryStream> callback)
{
Callback = callback;
// Form the URI
UriBuilder fullUri = new UriBuilder(urlPath);
if (!string.IsNullOrEmpty(data))
fullUri.Query = data;
// Initialize a new WebRequest
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUri.Uri);
request.Method = "POST";
// Set up the state object for the async request
DataUpdateState dataState = new DataUpdateState();
dataState.AsyncRequest = request;
// Start the asynchronous request
request.BeginGetResponse(new AsyncCallback(HandleResponse),
dataState);
}
private void HandleResponse(IAsyncResult asyncResult)
{ …Run Code Online (Sandbox Code Playgroud) 以下代码是非法的(Visual Studio 2012 Windows Phone(创建Windows Phone direct3d应用程序))
a non-value type cannot have any public data members 'posX'
Run Code Online (Sandbox Code Playgroud)
头
ref class Placement sealed
{
public:
Placement(
float rotX,
float rotY,
float rotZ,
float posX,
float posY,
float posZ
);
float rotX, rotY, rotZ, posX, posY, posZ;
};
Run Code Online (Sandbox Code Playgroud)
CPP
Placement::Placement(
float rotX,
float rotY,
float rotZ,
float posX,
float posY,
float posZ
)
: posX( posX ),
posY( posY ),
posZ( posZ )
{
this->rotX = static_cast<float>(rotX);
this->rotY = static_cast<float>(rotY);
this->rotZ = …Run Code Online (Sandbox Code Playgroud) 我有一个小行星类:
class Asteroid
{
public:
Asteroid();
float GetMovementSpeed();
float GetRotationSpeed();
Placement^ GetCurrentOrientation();
void UpdateOrientation( Placement^ placement );
float GetPosX();
float GetPosY();
float GetPosZ();
float GetRotX();
float GetRotY();
float GetRotZ();
private:
float movementSpeed;
float rotationSpeed;
Placement^ placement;
//float x;
//float y;
//float z;
//float rotX;
//float rotY;
//float rotZ;
};
Run Code Online (Sandbox Code Playgroud)
我已经设置了以下向量并用小行星填充它:) ...
vector<Asteroid*> asteroids;
asteroids.push_back( new Asteroid() );
asteroids.push_back( new Asteroid() );
asteroids.push_back( new Asteroid() );
for(std::vector<Asteroid*>::iterator asteroid = asteroids.begin(); asteroid != asteroids.end(); ++asteroid)
{
asteroid-> //Can't access the methods of …Run Code Online (Sandbox Code Playgroud) 例如,如果我希望我的类属性可以这样命名为笑:
class Product
{
[Key]
int ProductID {get;set;}
[Required]
string TitleTOTHEMAX {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我的Sql表有2列"ProductID"和"Title",我怎么告诉类的属性将自己映射到"Title"列,考虑到"TitleTOTHEMAX"列不存在:)
c# entity-framework data-annotations visual-studio-2013 asp.net-mvc-5
我有以下三个标题:
IBaseStates.h
class IBaseStates
{
public:
enum STATE;
virtual void Update( STATE state ) = 0;
};
Run Code Online (Sandbox Code Playgroud)
PlayerStates.h
#pragma once
#include "IBaseStates.h"
#include "Player.h"
class PlayerStates : public IBaseStates, public Player
{
public:
enum STATE {
FLYING,
FALLING
};
int textureAmount;
PlayerStates();
~PlayerStates( );
void Update( STATE state );
};
Run Code Online (Sandbox Code Playgroud)
Player.h
#pragma once
#include "StructVertex.h"
#include "SquareVertices.h"
#include "WICTextureLoader.h"
using namespace Microsoft::WRL;
using namespace DirectX;
//using namespace DirectX;
class Player : public SquareVertices
{
public:
Player( ComPtr<ID3D11Device1> d3dDevice );
~Player(); …Run Code Online (Sandbox Code Playgroud) 如果我有:
var greeter: Greeter = new Sausage();
Run Code Online (Sandbox Code Playgroud)
并且Greeter类和Sausage类都具有相同的功能和属性,变量greeter将很高兴地填满Sausage... ...我怎么能阻止它?
例如,以下代码编译正常:(
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
class Sausage {
size: number;
name: string;
greeting: string;
constructor() {
this.size = this.SausageLogic();
}
private SausageLogic(): number {
return this.size * 3;
}
greet() {
return "Hello, ";
}
}
var greeter: Greeter = new Sausage();
Run Code Online (Sandbox Code Playgroud) 有什么区别:
public List<MyType> Something{ get; set; } = new List<MyType>();
Run Code Online (Sandbox Code Playgroud)
和
public List<MyType> Something{
get{
return new List<MyType>();
}
//set...
}
Run Code Online (Sandbox Code Playgroud)
上下文:
我不确定我在代码中看到的行为.构造函数null上有一个服务,但在未来的方法调用中,我假设的是类的相同实例.
c# ×5
c++ ×3
pointers ×2
api ×1
asynchronous ×1
c++-cx ×1
delegates ×1
direct3d ×1
json ×1
mysql ×1
properties ×1
sql ×1
typescript ×1
vector ×1
where ×1