我有这个结构
Customer
- has many Orders
- has many OrderItems
Run Code Online (Sandbox Code Playgroud)
我想生成一个CustomerItemsvia LINQ 列表给出一个子集OrderItems:
List of new { Customer, List<OrderItem> Items }
Run Code Online (Sandbox Code Playgroud)
这是客户从商品子集中订购的所有商品的分组
我如何使用LINQ来跟踪客户的订单和分组以生成此对象?
到目前为止,我有点像
items
.GroupBy(i => i, i => i.Order.Customer, (i, customer) => new {customer, i})
Run Code Online (Sandbox Code Playgroud)
但那显然不是列表.我猜我在那里需要一个SelectMany,但是可以用一些指针来做.
我用Google搜索并环顾四周有没有人知道任何隐藏的宝石,这不是谷歌搜索的前几页....
试图让angular-cli识别出多个配置 angular.json
C:\_dev\myapp>ng serve --configuration development
Configuration 'development' could not be found in project 'myapp'.
Error: Configuration 'development' could not be found in project 'myapp'.
Run Code Online (Sandbox Code Playgroud)
该片段是:
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.production.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"development": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.development.ts"
}
],
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": true,
"aot": …Run Code Online (Sandbox Code Playgroud) 我在本地测试应用内订阅产品时遇到此错误.
验证是必需的.您需要登录您的Google帐户
我能够检查产品的库存但不应该也能购买它吗?
有很多帖子说明为什么会出现这个错误,我认为这个问题得到解决:
是通过beta/alpha频道测试实际购买的唯一方法 - 不是直接来自android studio.这篇文章表明它有可能(见屏幕截图)
http://developer.android.com/google/play/billing/billing_testing.html#billing-testing-test
android in-app-purchase in-app-billing google-play android-studio
当只能在运行时推断类型时,您将如何使用反射来执行以下方法?
MainObject.TheMethod<T>(Action<OtherObject<T>>)
Run Code Online (Sandbox Code Playgroud)
在日常使用中,通常:
mainObject.Method<Message>(m => m.Do("Something"))
Run Code Online (Sandbox Code Playgroud)
因此,给定一个类型列表,我需要在上面的方法中将它们替换为T并调用.
这是我在变成腻子之前得到的地方:
var mapped = typeof(Action<OtherObject<>>).MakeGenericType(t.GetType());
Activator.CreateInstance(mapped, new object[] { erm do something?});
typeof(OtherObject)
.GetMethod("TheMethod")
.MakeGenericMethod(t.GetType())
.Invoke(model, new object[] { new mapped(m => m.Do("Something")) });
Run Code Online (Sandbox Code Playgroud)
更新:为了澄清,我有一个类型列表,我希望为每个类型执行相同的已知方法.伪代码:
foreach(var t in types)
{
mainObject.TheMethod<t>(mo => mo.Do("Something"))
}
Run Code Online (Sandbox Code Playgroud)
(TheMethod()的参数类型Action<OtherObject<T>>如上所述)
FluentNHibernate.Automapping.AutoPersistenceModel Override<T>(System.Action<AutoMapping<T>> populateMap)
Run Code Online (Sandbox Code Playgroud)
行动是一样的 AutoMapping<T>.Where("something")
model.Override<Message>(m => m.Where("DeletedById is null"))
Run Code Online (Sandbox Code Playgroud)
现在,为一堆类型做到这一点:)
任何人都可以解释为什么实体连接而不是id生成一些非常丑陋的SQL实际上在概念上它做你认为是同样的事情?例如
通过id
from companyDirector in CompanyDirectors
join contactAddress in ContactAddresses
on companyDirector.ContactAddress.Id equals contactAddress.Id
select new {companyDirector, contactAddress}
Run Code Online (Sandbox Code Playgroud)
生成
FROM [COMPANY] AS [Extent1]
INNER JOIN [ADDRESS] AS [Extent2] ON [Extent1].[CONTACT_ADDRESS_ID] = [Extent2].[CONTACT_ADDRESS_ID]
Run Code Online (Sandbox Code Playgroud)
通过实例
from companyDirector in CompanyDirectors
join contactAddress in ContactAddresses
on companyDirector.ContactAddress equals contactAddress
select new {companyDirector, contactAddress}
Run Code Online (Sandbox Code Playgroud)
生成
FROM [COMPANY] AS [Extent1]
INNER JOIN [ADDRESS] AS [Extent2] ON EXISTS (SELECT
1 AS [C1]
FROM ( SELECT 1 AS X ) AS [SingleRowTable1]
LEFT OUTER JOIN (SELECT
[Extent3].[CONTACT_ADDRESS_ID] AS …Run Code Online (Sandbox Code Playgroud) 我有3个根组件,由root引导AppModule.
你如何@Input()为其中一个组件指定参数?
也不
<app-modal [id]="'hard-coded value'"></app-modal>
<app-modal [id]="constantExportedByAppmodule"></app-modal>
Run Code Online (Sandbox Code Playgroud)
通过AppModalComponent以下方式获取:
@Input() id: string;
Run Code Online (Sandbox Code Playgroud)
这是未定义的.
我想知道是否可以挂钩angular-cli的build/watch命令:
ng build/w
它生成文件并将它们放在项目的/dist文件夹中
我只是想在构建完成后将dist文件夹复制到另一个目录,是否可能?
我有以下指令应用于输入标记.当在主机组件上运行jasmine规范时,我希望它忽略(模拟)这个指令,因为它依赖于我对测试不感兴趣的jquery.
我试图创建一个MockDirective类,但没有成功.谁知道怎么做到这一点?
@Directive({
selector: '[skinColorPicker]'
})
export class ColorPickerDirective implements OnInit {
@Input('skinColorPicker') initialColor;
@Output() colorSelected: EventEmitter<string> = new EventEmitter<string>();
constructor(private el: ElementRef) {}
ngOnInit() {
// legacy jQuery blah blah
}
}
Run Code Online (Sandbox Code Playgroud)
在主持人内:
<input skinColorPicker="'#555'" (colorSelected)="onPageBackgroundColorSelected($event)"
/>
Run Code Online (Sandbox Code Playgroud)
规格:
describe('PrintSidebarComponent', () => {
let component: PrintSidebarComponent;
let fixture: ComponentFixture<PrintSidebarComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
PrintSidebarComponent,
MockDirective({ selector: '[skinColorPicker]' }) // does not work
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PrintSidebarComponent);
component = fixture.componentInstance;
fixture.detectChanges(); …Run Code Online (Sandbox Code Playgroud) 我已经浏览了文档,但找不到帮助程序来重置 Luxon DateTime 的时间。
我可以从一个标准日期开始:
export const getDateOnly = (date: Date = new Date()) => new Date(
date.getFullYear(),
date.getMonth(),
date.getDate()
)
export const today = () => DateTime.fromJSDate(getDateOnly());
Run Code Online (Sandbox Code Playgroud)
但这似乎是一个常见的场景,我可能只是错过了它?
angular ×4
angular-cli ×2
c# ×2
.net ×1
android ×1
angular6 ×1
date ×1
generics ×1
google-play ×1
group-by ×1
jasmine ×1
javascript ×1
join ×1
linq ×1
luxon ×1