我有一张桌子
`CREATE TABLE IF NOT EXISTS `PROGETTO`.`ALBERGO` (
`ID` INT(11) NOT NULL COMMENT 'identificativo dell\' albergo' ,
`nome` VARCHAR(45) NULL COMMENT 'Il nome dell\'albergo' ,
`viale` VARCHAR(45) NULL COMMENT 'Il viale in cui si trova ' ,
`num_civico` VARCHAR(5) NULL COMMENT 'Il numero civico che gli appartiene' ,
`data_apertura` DATE NULL COMMENT 'Data di inizio apertura (inizio stagione)' ,
`data_chiusura` DATE NULL COMMENT 'Data di chiusura (fine stagione)' ,
`orario_apertura` TIME NULL COMMENT 'Orario di apertura' ,
`orario_chiusura` TIME NULL …Run Code Online (Sandbox Code Playgroud) 我似乎无法完全理解代码中聚合和组合之间的区别.
客户<.> ----> BankAccount
(这应该是Client - BankAccount组合类图).
所以在这个例子中,客户有一个银行账户,这意味着,当客户对象死亡时,他的银行账户对象也会死亡.这是否意味着我们必须在Client类中拥有BankAccount对象?
Class Client
{
BankAccount acc = new BankAccount();
public void addMoneyToBankAccount(decimal amount)
{
acc.AddMoney(amount);
}
public decimal CheckBalance()
{
return acc.CheckAccountBalance();
}
}
Run Code Online (Sandbox Code Playgroud)
那么,这个组成是代码吗?在这个例子中,聚合会是什么样的?抱歉新手问题,如果代码错误,请纠正我.提前致谢.
我需要模拟HttpContext进行单元测试.但我正在努力解决它.
我正在创建一个方法,通过SessionIdManager以编程方式更改sessionId.而SessionIdManager需要HttpContext而不是HttpContextBase.
但我找不到任何模拟HttpContext的例子.所有的例子都只是制作HttpContextBase.
我在下面试过,但他们没有用
HttpContext httpContext = Mock<HttpContext>();
HttpContext httpContext = (HttpContext)GetMockHttpContextBase();
public HttpContextBase GetMockHttpContextBase()
{
var context = new Mock<HttpContextBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
var session = new Mock<HttpSessionStateBase>();
var application = new Mock<HttpApplication>();
var httpContext = new Mock<HttpContext>();
var server = new Mock<HttpServerUtilityBase>();
var user = new Mock<IPrincipal>();
var identity = new Mock<IIdentity>();
var urlHelper = new Mock<UrlHelper>();
var routes = new RouteCollection();
var requestContext = new Mock<RequestContext>();
requestContext.Setup(x => x.HttpContext).Returns(context.Object);
context.Setup(ctx …Run Code Online (Sandbox Code Playgroud) 例如,有一些日期表:
2015-01-01
2015-01-02
2015-01-03
2015-01-06
2015-01-07
2015-01-11
Run Code Online (Sandbox Code Playgroud)
我必须编写ms sql查询,它将返回从表中每个日期开始的连续日期的计数.结果如下:
2015-01-01 1
2015-01-02 2
2015-01-03 3
2015-01-06 1
2015-01-07 2
2015-01-11 1
Run Code Online (Sandbox Code Playgroud)
在我看来,我应该使用LAG和LEAD功能,但现在我甚至无法想象思维方式.
为什么在这部分代码中complete被缓存?
static void Main()
{
bool complete = false;
var t = new Thread (() =>
{
bool toggle = false;
while (!complete) toggle = !toggle;
});
t.Start();
Thread.Sleep (1000);
complete = true;
t.Join(); // Blocks indefinitely
}
Run Code Online (Sandbox Code Playgroud)
但在这部分不是吗?
static void Main()
{
bool complete = false;
bool toggle = false;
var t = new Thread (() =>
{
while (!complete) toggle = !toggle;
});
t.Start();
Thread.Sleep (1000);
complete = true;
t.Join();
}
Run Code Online (Sandbox Code Playgroud) 我想要一个具有重复多次值的列,并且只获取该值一次并将其存储以供以后使用,但同时我希望在与该不同列相同的行中获得另一个值.
A B C
32263 123456 44
32263 123456 45
32263 123456 46
32264 246802 44
32263 246802 45
32264 246802 46
32265 369258 44
32265 369258 45
32265 369258 46
Run Code Online (Sandbox Code Playgroud)
A,B,C代表三列.现在忽略C.
我的问题是:如何在此表中获取此信息并将其存储,以便稍后在脚本中使用它?
这是我尝试过的:
use databaseName
select distinct A from tableName
order by A
Run Code Online (Sandbox Code Playgroud)
结果是:
A
32263
32264
32265
Run Code Online (Sandbox Code Playgroud)
我试图让它也给我B的价值.(注意,无论我选择哪一行都没关系,因为无论AI选择什么,B的值对于给定的A都是相同的.)我们现在忽略C.
结果应该是:
A B
32263 123456
32264 246802
32265 369258
Run Code Online (Sandbox Code Playgroud)
现在,一旦我得到它,我想使用从查询中获得的值插入一行.这就是C的用武之地.我想做这样的事情:
use databaseName
insert into tableName (A, B, C)
values (32263, 123456, 47)
Run Code Online (Sandbox Code Playgroud)
当然我不希望将值直接放在那里,而是有一些循环,它将遍历我找到的3个不同A值中的每一个.
简而言之,我的桌子应该来自:
A B C
32263 123456 44 …Run Code Online (Sandbox Code Playgroud) 我有以下代码附加事件处理程序:
this.btnOK.Click += (s,e) => { MessageBox.Show("test"); };
Run Code Online (Sandbox Code Playgroud)
我可以从通风口取消订阅lambda表达吗?
我正在向REST服务发出HTTP post请求,当我收到HttpWebResponse时,我正在进行下面的检查.当我在做webresponse时,我还应该检查responseStream!= null!= null
HttpWebResponse webResponse = webRequest.GetResponse() as HttpWebResponse;
if (webResponse != null)
{
var responseStream = webResponse.GetResponseStream();
int responseCode = (int)webResponse.StatusCode;
if (responseStream != null && responseCode == (int)HttpStatusCode.Created)
{
cmsStoreWebResponse = ((new StreamReader(responseStream)).ReadToEnd());`
}
else
{
this.LogError(string.Format("{0}\n Endpoint: {1}\n {2} {3} {4}", ErrorCodes.IWS_CMSRetrieve_ERROR_001, oagEndpointUrl, ErrorCodes.IWS_CMSStore_ERROR_SERVICE_DOWN, responseStream, responseCode));
serviceData.Fatal = true;
serviceData.ErrorCode = ErrorCodes.IWS_EFORMSFORMSETS_001;
serviceData.ErrorDetails = string.Format("\nEndpoint: {0}\n {1}", oagEndpointUrl, ErrorCodes.RESPONSE_STREAM_NULL);
throw new FaultException<ServiceExceptionData>(serviceData, new FaultReason(string.Format("\nEndpoint: {0}\n {1}", oagEndpointUrl, ErrorCodes.RESPONSE_STREAM_NULL)));
}
}
else
{
this.LogError(string.Format("{0}\n Endpoint: {1}\n {2}", …Run Code Online (Sandbox Code Playgroud) 如何TreeView在扩展节点时更改其宽度,以便节点的标签完全显示.
首先我设置了 DrawMode = OwnerDrawAll;
然后处理事件DrawNode和处理程序
e.DrawDefault = true;
currentWith_ = Math.Max(currentWith_, e.Node.Bounds.Right);
Run Code Online (Sandbox Code Playgroud)
然后用AfterExpand控件设置控件.但每次都不行.有时不更改或更改不正确.
如何纠正这个问题.提前致谢.
此代码段ConcurrentQueue来自此处给出的实现。
internal bool TryPeek(out T result)
{
result = default(T);
int lowLocal = Low;
if (lowLocal > High)
return false;
SpinWait spin = new SpinWait();
while (m_state[lowLocal] == 0)
{
spin.SpinOnce();
}
result = m_array[lowLocal];
return true;
}
Run Code Online (Sandbox Code Playgroud)
它真的是无锁的,而不是旋转的吗?