通常要通过命令行启动,我可以输入:
babel-node server.js
Run Code Online (Sandbox Code Playgroud)
当我尝试将其设置为断点以及在我收到的visual studio代码中不起作用时:
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js --debug-brk=31893 --nolazy server.js
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 1: /Applications: is a directory
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 3: /Applications: is a directory
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 4: Dockerfile: command not found
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 5: syntax error near unexpected token `('
/Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 5: ` * when found, before invoking the "real" _babel-node(1) executable.'
Run Code Online (Sandbox Code Playgroud)
我猜测它与从该目录调用可执行文件的事实有关,而不是与server.js文件在同一目录中 - 但我真的不知道.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/server.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": "${workspaceRoot}/node_modules/babel-cli/lib/babel-node.js", …Run Code Online (Sandbox Code Playgroud) 我正在循环运行并以下列方式开始执行任务:
var iResult = new List<Task>();
foreach(var i in myCollection)
{
var task = Task.Factory.StartNew(() =>
DoSomething(), TaskCreationOptions.LongRunning);
task.ContinueWith(m => myResponseHandler(m.Result));
iResult.Add(task);
}
Run Code Online (Sandbox Code Playgroud)
在我的DoSomething()方法中,我有一个计时器:
public static myMsg DoSomething()
{
var timer = System.Diagnostics.Stopwatch.StartNew();
DoLongRunningTask(); //If it matters this hits a REST endpoint (https)
timer.Stop();
return new myMsg(timer.ElaspedMilliseconds);
}
Run Code Online (Sandbox Code Playgroud)
当我遍历我的列表时,myMsgElaspedMilliseconds似乎完全是加法的 - 第一个上的ElaspedMilliseconds可能是300,但最后一个可能是50000(50秒) - 这实际上是整个事情所需的大致时间运行(由另一个计时器测量).
我做了下表:
create table temp.promotions_xml(id serial promotion_xml xml);
Run Code Online (Sandbox Code Playgroud)
我已将以下数据插入temp.promotions:
<promotions xmlns="http://www.demandware.com/xml/impex/promotion/2008-01-31">
<campaign campaign-id="2013-1st-semester-jet-giveaways">
<description>2013 1st Semester Jet Giveaways</description>
<enabled-flag>true</enabled-flag>
<start-date>2013-01-01T05:00:00.000Z</start-date>
<end-date>2013-07-01T04:00:00.000Z</end-date>
<customer-groups>
<customer-group group-id="Everyone"/>
</customer-groups>
</campaign>
</promotions>
Run Code Online (Sandbox Code Playgroud)
数据在表中.
我无法弄清楚如何解决它.我可能希望能够填充我将构建的关系模型,所以我想摆脱所有标签.
以下是我尝试过的一些不起作用的查询.我很确定我只是围绕正确的语法跳舞.这些查询返回空集的行.
FWIW,我们正在使用Postgres 9.0.4.
谢谢, - 谢谢
select xpath('/promotions/campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('./promotions/campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('promotions/campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('///description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('//description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('.//description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('./campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
select xpath('//campaign/description/text()',promotion_xml) textcol from temp.promotions_xml
Run Code Online (Sandbox Code Playgroud) 我有使用的Java代码SortedMap.tailMap。在我的移植代码中,我有SortedMap= Dictionary<IComparable, value>。我需要一种在C#中复制/模仿tailMap的方法。
我已经想到了以下内容:
myDictionary.Where(p => p.Key.CompareTo(value) >= 0).ToDictionary
这将返回Dictionary,而我需要SortedDictionary返回。我可以SortedDictionary从中创建一个Dictionary,但是我觉得应该已经有一种更好的,更优雅的方法来做到这一点。
另一个想法是做类似的事情
var newSD = new SortedDictionary<k,v>();
foreach (var p in oldDictionary.Where(p => p.Key.CompareTo(value) >= 0))
newSD.Add(p.Key, p.Value);
Run Code Online (Sandbox Code Playgroud)
那应该行得通,我不确定在构建列表时按排序顺序添加值将如何影响插入的时间。
还有其他想法吗?
我正在努力与使用MVC 6和EF7的ASP.NET vNext构建Web系统相处.我正在看这个教程:http://stephenwalther.com/archive/2015/01/17/asp-net-5-and-angularjs-part-4-using-entity-framework-7
在页面上,您将看到如何将dbContext添加到项目中,并在启动文件中注册,如下所示:
// Register Entity Framework
services.AddEntityFramework(Configuration)
.AddSqlServer()
.AddDbContext<MoviesAppContext>();
Run Code Online (Sandbox Code Playgroud)
上下文类看起来像这样:
public class MoviesAppContext:DbContext
{
public DbSet<Movie> Movies { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这一切都很好,但现在我需要添加一个额外的DbContext.虽然我不知道如何注册这个额外的上下文,以便它将被EF使用并可能在我的项目中使用.
假设我已经创建了一个像这样的新上下文:
public class MyNewSuper:DbContext
{
public DbSet<Model1> Model1 { get; set; }
public DbSet<Model2> Model2 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我如何继续注册它以便在我的项目中使用呢?
c# asp.net asp.net-mvc entity-framework entity-framework-core
我想以反向格式打印字符串:
输入: My name is Archit Patel
输出:Patel Archit is name My.
我绑了以下但显示为letaP tihcrA si eman ym.
public static string ReverseString(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
Run Code Online (Sandbox Code Playgroud) 我一直试图解决关于风寒的这个公式,我得到了结果,但我需要在小数点后面有更多的数字.无论我尝试过什么都行不通.请帮忙!
static void Main()
{
double temp = 20;
double wind = 7;
double windChill = 35.74 + 0.6215 * temp + (0.4275 * temp - 35.75) * Math.Pow(wind, 0.16);
Console.WriteLine("so wind_chill = {0}", Math.Round(windChill, 15));
}
Run Code Online (Sandbox Code Playgroud)
在这里,我得到最终号码11.03490062551,但我想要11.034900625509998.我究竟做错了什么?
我有一个外部打开套接字的云服务,需要白名单的IP地址.外部任何东西都不会启动与我的服务的连接.
当我尝试使用关联的ReservedIP地址发布它时,我收到以下错误: Validation Errors: Error validating the .cscfg file against the .csdef file. Severity:Error, message:ReservedIP 'xxxx' was not mapped to an endpoint. The service definition must contain atleast one endpoint that maps to the ReservedIP..
.cscfg
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="Gateway" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="5" osVersion="*" schemaVersion="2015-04.2.6">
<Role name="WorkerRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="yyyyy" />
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" value="xxx" />
<Setting name="ASPNETCORE_ENVIRONMENT" value="dev" />
</ConfigurationSettings>
</Role>
<NetworkConfiguration>
<AddressAssignments>
<ReservedIPs>
<ReservedIP name="xxxxx"/>
</ReservedIPs>
</AddressAssignments>
</NetworkConfiguration>
</ServiceConfiguration>
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的简化版本,只是为了让您知道我想要完成的任务:
public Dictionary<int, Func<int>> Magic(Dictionary<int, int> dictionary)
{
return dictionary
.Select(v => new
{
key = v.Key,
function = new Func<int>(() => v.Value + 5) // *
})
.ToDictionary(v => v.key, v => v.function);
}
Run Code Online (Sandbox Code Playgroud)
是否可以将标有(*)的线缩短一些?因为当我尝试删除多余的(在我看来)委托创建时,它会给出错误:
function = () => v.Value + 5 // *
Run Code Online (Sandbox Code Playgroud)
但它不应该给出错误,很清楚返回的类型是什么......
我有一个位掩码(存储为短).出于各种目的,我想将除最后5位之外的所有内容归零 - 我确信通过按位运算符可以很容易地实现这一点,但它让我望而却步.
1010 01101 1011 0111 -> 0000 0000 0001 0111
Run Code Online (Sandbox Code Playgroud)
谢谢
我需要在EF6中以多对多的关系从连接表中返回单个列
User { Id, Name}
Role { Id, Role}
UserToRole { UserId, RoleId}
Run Code Online (Sandbox Code Playgroud)
这是一个简化的示例,但我需要从User获取RoleId(Role.Id)的列表.
理想情况下,我只是做类似的事情
context.UserToRole.Where(x => x.UserId == id).Select(r => r.RoleId).ToList();
Run Code Online (Sandbox Code Playgroud)
但EF似乎并没有为我提供该连接表作为查询对象.
我知道我可以将所有角色作为对象拉下来,但在我的实际系统中,这是一个宽表,我想避免将所有数据拉到线上并将其放入内存的开销.
我在asp.net(C#)中使用accessor/mutators来分配和获取值.
我有两个事件:
protected void ddlDepartments_SelectedIndexChanged(object sender, EventArgs e)
{
accessVariables.DepID = Convert.ToInt32(ddlDepartments.SelectedValue);
}
protected void chkIsHead_CheckedChanged(object sender, EventArgs e)
{
Response.Write(accessVariables.DepID);
}
Run Code Online (Sandbox Code Playgroud)
它称之为:
public class AccessibleVariables
{
public int depID { get; set; }
public int DepID
{
get { return depID; }
set { depID = value; }
}
}
Run Code Online (Sandbox Code Playgroud)
第二个事件返回0,为什么?我运行调试器,我检查,(设置)分配实际值,这是完美但得到不返回实际值,它总是返回0,为什么?