我有这个简单的LINQ查询,执行8395毫秒:
var _context = new SurveyContext();
_context.Database.Log = Console.WriteLine;
(from p in _context.Participants
join row in _context.ListAnswerSelections
on new {p.Id, QuestionId = 434} equals
new {Id = row.RelatedParticipantId, QuestionId = row.RelatedQuestionId}
select new { V = row.NumericValue.ToString() })
.ToList()
.Select(x => new {R = x.V})
.Count() //This is just to see one number instead of whole result
.Dump("Results");
Run Code Online (Sandbox Code Playgroud)
它的IL:
IL_0000: nop
IL_0001: newobj Survey.Model.SurveyContext..ctor
IL_0006: stloc.0 // _context
IL_0007: ldloc.0 // _context
IL_0008: callvirt System.Data.Entity.DbContext.get_Database
IL_000D: ldnull
IL_000E: ldftn System.Console.WriteLine …Run Code Online (Sandbox Code Playgroud) 我有带有Web.conig文件的ASP.NET WEB API项目.在VS2015中构建时,不会报告错误和警告.但是,当我使用MSBuild构建步骤在TeamCity上构建此项目时,我收到警告MSB3247:
[ResolveAssemblyReferences] ResolveAssemblyReference
[14:30:01] : [ResolveAssemblyReference] No way to resolve conflict between "protobuf-net, Version=2.0.0.602, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" and "protobuf-net, Version=2.0.0.480, Culture=neutral, PublicKeyToken=257b51d87d2e4d67". Choosing "protobuf-net, Version=2.0.0.602, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" arbitrarily.
[14:30:01] : [ResolveAssemblyReference] No way to resolve conflict between "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
[14:30:01] : [ResolveAssemblyReference] Consider app.config remapping of assembly "protobuf-net, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" from Version "2.0.0.602" [] to Version "2.0.0.668" [D:\TeamCity\buildAgent\work\2772494ce0e0bbd7\branches\Stategic.Window.Release1\src\Strategic.Window\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll] to solve conflict and get rid of warning. …Run Code Online (Sandbox Code Playgroud) I have to migrate from CircleCI 1.0 to 2.0. After I have changed the old configuration to the new one, build failed because of eslint-plugin-prettier reported prettier spacing violations.
MyProject - is my GitHub repo and it contains a folder client which has all front-end code which I want to build on CI. In client folder there are
.eslintrc.json
...
"extends": ["airbnb", "prettier"],
"plugins": ["prettier"],
...
Run Code Online (Sandbox Code Playgroud)
.prettierrc
{
"tabWidth": 4,
"trailingComma": "all",
"singleQuote": true
}
Run Code Online (Sandbox Code Playgroud)
.gitattributes (I work on Windows …
对象传播广泛用于更新功能样式中的旧对象,如下所示:
let o1 = { x: 5, y: 6 };
let o2 = { ...o1, y: 10 };
alert(JSON.stringify(o2));
Run Code Online (Sandbox Code Playgroud)
在新的TypeScript 2.1中,我们现在实现了对象扩展,但与简单对象文字不同,它允许具有未知属性:
interface Point { x: number, y: number }
let o1: Point = { x: 5, y: 6 };
//ERROR: Object literal may only specify known properties
let o2: Point = { x: 5, y: 6, z: 10 };
// OK: had I wanted to update y, but misspeled it,
// I would get new "z" prop instead of compiler …Run Code Online (Sandbox Code Playgroud) 从打字稿规范:
Null 类型是所有类型的子类型,Undefined 类型除外。未定义类型是所有类型的子类型。
据此,我相信,我们可以得出结论,它undefined是 的一个子类型null,例如number。我们不能将超类型分配给子类型,例如,number不可分配给undefined. 为什么null,虽然是超类型 toundefined可分配给undefined?
let x: undefined;
x = 5; // Error
let y: undefined;
y = null; // OK
Run Code Online (Sandbox Code Playgroud) 我必须在APL中编码.由于代码将被维护很长一段时间,我想知道是否有一些论文/书籍包含启发式/提示/样本,以帮助设计清洁和可读的APL程序.
与使用其他编程语言编码不同,这是一种不同的体验.例如,制作一个功能.Small无济于事:这样的函数可以包含一行代码,这是完全不可理解的.
我已经在 VS 2015 中对我的所有解决方案项目设置了代码分析,并且运行良好。在其中一个项目中,有 .ruleset 文件,所有其他项目都引用该文件作为其代码分析的规则集。现在我希望在 TeamCity 上运行相同的代码分析,TeamCity 在没有安装 VS 的情况下在 Windows Server 2012 R2 上运行。
我已经尝试/p:RunCodeAnalysis=True作为这里建议的 MSBuild 步骤的命令行参数。但是这个选项显然被忽略了,因为构建日志没有说明运行代码分析的任何内容。我没有设置 FxCop 构建步骤,因为它需要指向 .dll 文件,但我希望代码分析实际分析我的解决方案中的代码,而不是 IL。
这里提出的解决方案是唯一可能的吗?对我来说,它看起来有点像一个容易出错的 hack。
根据干净代码法,我们希望拥有只做一件事并且处于相同“抽象级别”的函数。但是如何命名函数,它的工作只是检查某些条件并在条件为真时执行工作。例如,这个函数如何命名?
public void HowToNameThis(){
if(!ComponentIsInstalled()){
DisableCheckbox();
}
}
Run Code Online (Sandbox Code Playgroud)
我想过将其命名为“DisableCheckboxIfComponentIsNotInstalled”,但是这个名称只是重复了代码,这实际上意味着我已经创建了一个函数,但没有创建任何抽象。
我有以下示例代码:
//Derived type of sum ([head, ...tail]: number[]) => any
let sum =
([head, ...tail]: number[]) => head ? head + sum(tail) : 0
let x: string = sum([1, 2, 3]);
alert(x);
Run Code Online (Sandbox Code Playgroud)
为什么 TypeScript 推断出productto be的返回类型any?Flow 报告了此代码的错误,我相信该错误是正确的。
所有
我有三个系列:
{"Alex", "Anna"}
{19, 20}
{"A", "B"}
Run Code Online (Sandbox Code Playgroud)
我想使用LINQ和以下lambda或其他东西将它们全部投射到"Student"类型的一个对象序列中:
(name, age, grade)=>new Student(name, age, grade)
Run Code Online (Sandbox Code Playgroud)
结果应该是两个学生对象("Alex",19,"A")和("Anna",20,"B")
我怎样才能做到这一点?
c# ×3
typescript ×3
linq ×2
msbuild ×2
teamcity ×2
.net ×1
apl ×1
asp.net ×1
circleci ×1
coding-style ×1
eslint ×1
prettier ×1
readability ×1
sql-server ×1