我有以下类结构:
public class PriceLog
{
public DateTime LogDateTime {get; set;}
public int Price {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
对于List <PriceLog>,我希望Linq查询生成一个输出,该输出等效于如下所示的数据:
LogDateTime | AVG(价格)
2012年1月| 2000年
2月2012 | 3000
简单地说:我想计算一年中每个月的平均价格.
注意:LogDateTime属性应格式化为LogDateTime.ToString("MMM yyyy")
我尝试了以下内容,但不确定它是否会产生所需的结果:
var result = from priceLog in PriceLogList
group priceLog by priceLog.LogDateTime.ToString("MMM yyyy") into dateGroup
select new PriceLog { GoldPrice = (int)dateGroup.Average(p => p.GoldPrice), SilverPrice = (int)dateGroup.Average(p => p.SilverPrice)};
Run Code Online (Sandbox Code Playgroud) 现在,我定义一个新的Custom List Definition
内Custom Content Type
,这个问题简单说就是Title
与列表相关的字段不能被隐藏,我也跟着在下面的链接,但没有成功找到了一些方法.
简单地添加List definition
而不实现内容类型会使Title字段消失,但在定义内容类型及其字段时,它始终可见.
Elements.xml的
<ContentType ID="0x01003EBF692DD17B4F71966712180C0D23D8" Name="ContactUsAssignments"
Description="Contact Us Assignments content type">
<FieldRefs>
<FieldRef ID="{4B888F48-A039-46D0-B2E1-C67802097069}"/>
<FieldRef ID="{6238a52d-2975-4e8a-9a1e-31b9cdc74129}"/>
<RemoveFieldRef ID="{D3D0DDF1-F791-4FFF-893C-0C100B724F1A}" />
</FieldRefs>
</ContentType>
Run Code Online (Sandbox Code Playgroud)
我也尝试过, Inherits="FALSE" Version="0"
但遗憾的是没有任何改变.
Schema.xml的
<ContentTypes>
<ContentTypeRef ID="0x01003EBF692DD17B4F71966712180C0D23D8"></ContentTypeRef>
</ContentTypes>
<Fields>
<Field Type="Text" DisplayName="Title" Required="FALSE"
ID="{D3D0DDF1-F791-4FFF-893C-0C100B724F1A}" StaticName="Title" Name="Title" Hidden="TRUE" />
</Fields>
Run Code Online (Sandbox Code Playgroud)
我不确切地知道我是否错过了什么,但这种方法很清楚.谢谢.
我有这样的查询,返回其我的用户名userid
是access
表users
,我要的是给我回那些userid
谁在没有用户access
:
var query = db.Users
.Join(db.Access, c => c.UserId, o => o.UserId,
(c, o) => new { c.UserId, c.Name });
Run Code Online (Sandbox Code Playgroud)
在SQL中它会是这样的:
SELECT Users.Name
FROM Access INNER JOIN
Users ON Access.UserId <> Users.UserId
Run Code Online (Sandbox Code Playgroud)
什么是lambda expression
sql脚本的等价物?
我使用以下代码datepicker
从jquery
日历中获取日期。当我为第一个字段选择日期时,该日期和时间也将输入到第二个字段中。
我需要的只是在第二个字段中输入日期和时间并添加 10 小时 (addHours(10))。我尝试了一些选择但没有成功。您能否建议将代码放在哪里.addHours(10)
才能在第二个字段中获取结果?
var startDateTextBox = $('#rest_example_4_start');
var endDateTextBox = $('#rest_example_4_end');
startDateTextBox.datetimepicker({
onClose: function(dateText, inst) {
if (endDateTextBox.val() != '') {
var testStartDate = startDateTextBox.datetimepicker('getDate');
var testEndDate = endDateTextBox.datetimepicker('getDate');
if (testStartDate > testEndDate)
endDateTextBox.datetimepicker('setDate', testStartDate);
} else {
endDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime) {
endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate'));
}
});
endDateTextBox.datetimepicker({
onClose: function(dateText, inst) {
if (startDateTextBox.val() != '') {
var testStartDate = startDateTextBox.datetimepicker('getDate');
var testEndDate = endDateTextBox.datetimepicker('getDate');
if (testStartDate > testEndDate) …
Run Code Online (Sandbox Code Playgroud) 这很尴尬,我很抱歉没有包含图表图像(我以为我包含了它,但我应该更加小心并在帖子中验证它)
我对 UML 几乎一无所知,但据我所知,一个空心箭头表示继承关系(即ANDSpecification
类继承自CompositeSpecification
class),而另一种类型的箭头告诉我们可以从 导航ANDSpecification
到CompositeSpecification
?
a) 但是为什么图表连接ANDSpecification
并CompositeSpecification
包含两种类型的箭头?也许是因为除了ANDSpecification
继承自之外CompositeSpecification
,它还具有 type 的属性CompositeSpecification
?
b) 箭头旁边的数字是什么意思?
c# ×2
linq ×2
custom-lists ×1
datepicker ×1
group-by ×1
jquery ×1
jquery-ui ×1
lambda ×1
sharepoint ×1
sql ×1
uml ×1
xml ×1