小编Tra*_*ain的帖子

如何过滤IQueryable <T>的嵌套项?

我正在构建一个类型的表达式,Expression<Func<Project, bool>>IQueryable<Project>从数据库返回正确的.IQueryable<Project>有一个SubProjects我想要过滤的嵌套集合.它看起来像这样

这可以通过一次调用数据库完成吗?

例如:

Expression<Func<Project, bool>> projectFilter = FilterEnabled();

projectFilter = projectFilter.And(GetProjectsByOrganization());

var projectData = GetProjectsAsQueryable(projectFilter); //returns correct projects
Run Code Online (Sandbox Code Playgroud)

这就是我想做的事情:

Expression<Func<Project, bool>> projectFilter = FilterEnabled();

projectFilter = projectFilter.And(GetProjectsByOrganization())
                             .And(GetSubProjectsByStartDate());

var projectData = GetProjectsAsQueryable(projectFilter); //returns correct projects and the filtered sub projects by start date
Run Code Online (Sandbox Code Playgroud)

GetProjectsByOrganization是如下

public Expression<Func<Project, bool>> GetProjectByOrganization()
{
    var organizationIDs = new List<Guid>();

    if (FilterCriteria.OrganiazaitonId != null)
        organizationIDs = OrganizationRepository.GetParentAndChildrenOrganizationIds(FilterCriteria.OrganiazaitonId.Value).ToList();

    //...

    return prj => FilterCriteria.OrganiazaitonId == null || …
Run Code Online (Sandbox Code Playgroud)

c# linq iqueryable

8
推荐指数
1
解决办法
317
查看次数

节点js与gmail api,API返回错误:错误:unauthorized_client

编辑:错误发生在这段代码上:

   var gmail = google.gmail('v1');
      gmail.users.labels.list({
        auth: auth,
        userId: 'me',
      }, function(err, response) {
        if (err) {
          console.log('The API returned an error: ' + err);
          return;
        }
Run Code Online (Sandbox Code Playgroud)

我正在使用带有Node js的gmail api.当我通过他们的快速入门指南时,我不断收到此错误.

https://developers.google.com/gmail/api/quickstart/nodejs

 The API returned an error: Error: unauthorized_client
Run Code Online (Sandbox Code Playgroud)

请记住,我通过电子邮件地址快速入门,一切都很好.完全没有错误.我决定创建一个虚拟电子邮件用于测试目的.我做的唯一更改是step 1-g切换client_secret.json文件以保存新凭据和密钥.我尝试切换回旧文件,但错误仍然存​​在.

在提供的链接页面的底部说明.

Authorization information is stored on the file system, so subsequent executions will not prompt for authorization. Would I have to clear or refresh the information? If so how can I do this?
Run Code Online (Sandbox Code Playgroud)

如果有帮助,我将重新发布我的quickstart.js文件中的所有代码.

var fs …
Run Code Online (Sandbox Code Playgroud)

javascript json oauth node.js gmail-api

7
推荐指数
1
解决办法
3264
查看次数

Angular 6 PrimeNG自定义编辑器

我正在尝试自定义我PrimeNG Editor要添加具有自定义字体大小的选择下拉列表[12px, 14px, 16px...]

这是组件 HTML

<p-editor [(ngModel)]="value" (onTextChange)="onTextChanged($event)">
            <p-header>
                    <span class="ql-formats">
                     ...
                      <select class="ql-size">
                            <option value="12px">12</option>
                            <option value="14px">14</option>
                            <option value="16px">16</option>
                        </select>
                    </span>
                   ...
                  </p-header>               
    </p-editor>
Run Code Online (Sandbox Code Playgroud)

我可以选择列表显示所有字体大小 在此处输入图片说明

我不确定在列表中选择一个选项时如何添加更改字体大小的功能。我没有在他们的文档中看到任何示例的打字稿。如何选择自定义字体大小的列表?

这是我关注的文档

typescript quill primeng angular

6
推荐指数
1
解决办法
1123
查看次数

cordova“ NSInternalInconsistencyException”,原因:“错误:config.xml不存在

我正在尝试为iOS运行一个新的hello world cordova应用程序。它总是在启动屏幕上崩溃。

但我不断收到错误

'NSInternalInconsistencyException', reason: 'ERROR: config.xml does not exist. Please run cordova-ios/bin/cordova_plist_to_config_xml path/to/project.

当我导航到hellocordva.xcodeproj并运行

run cordova-ios/bin/cordova_plist_to_config_xml . 它不是命令

这是config中的config.xml testapp/platforms/ios/HelloCordova的样子

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
    <preference name="AllowInlineMediaPlayback" value="false" />
    <preference name="BackupWebStorage" value="cloud" />
    <preference name="DisallowOverscroll" value="false" />
    <preference name="EnableViewportScale" value="false" />
    <preference name="KeyboardDisplayRequiresUserAction" value="true" />
    <preference name="MediaPlaybackRequiresUserAction" value="false" />
    <preference name="SuppressesIncrementalRendering" value="false" />
    <preference name="SuppressesLongPressGesture" value="false" />
    <preference name="Suppresses3DTouchGesture" value="false" />
    <preference name="GapBetweenPages" value="0" />
    <preference name="PageLength" value="0" />
    <preference name="PaginationBreakingMode" value="page" /> …
Run Code Online (Sandbox Code Playgroud)

xml ios cordova phonegap-cli

5
推荐指数
1
解决办法
2832
查看次数

Visual Studio 2015更新3和sql server 2016"visual studio CRC包没有正确加载"

我刚刚下载了Visual Studio 2015更新3.当我打开sql server时,我收到此错误消息,然后关闭sql server.

Visual studio 2015 update 3 and sql server 2016

activitylog.xml

`  </entry>
  <entry>
    <record>295</record>
    <time>2016/07/29 21:31:52.667</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Entering function CVsPackageInfo::HrInstantiatePackage</description>
    <guid>{6B238C39-B163-467E-83DB-A2DEC10459ED}</guid>
  </entry>
  <entry>
    <record>296</record>
    <time>2016/07/29 21:31:52.667</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Appid denied the loading of package</description>
    <guid>{6B238C39-B163-467E-83DB-A2DEC10459ED}</guid>
  </entry>
</activity>
`
Run Code Online (Sandbox Code Playgroud)

我尝试删除以下目录并重新启动vs但没有任何工作C:\ Users {your_username}\AppData\Roaming\Microsoft\VisualStudio\14.0

我也尝试修复vs并从头开始重新安装到更新2但没有任何工作.还有什么我可以尝试的吗?

visual-studio-2015 sql-server-2016

5
推荐指数
1
解决办法
2633
查看次数

React Native TouchableOpacity 对儿童不起作用

当我单击其中的子组件时,我有一个TouchableOpacity不会执行该事件的组件。onPressonpress 事件是一个简单的 console.log();

<TouchableOpacity style={{flex: 1}} onPress={this.onPress.bind(this)}>
    {this.state.customComponent}
</TouchableOpacity>
Run Code Online (Sandbox Code Playgroud)

如果我单击其中的空白区域TouchableOpacity将执行onPress. 如果我直接单击子组件,它将不会执行。

编辑:我发现了问题,这是因为TouchableOpacity它的子组件渲染了 aTouchableHighlight不幸的是你不能将 aTouchableHighlight作为孩子

javascript react-native

4
推荐指数
1
解决办法
3570
查看次数

如何添加材质图标

我正在尝试在我的应用程序中使用 Outlined 材质图标。我似乎无法正确导入它们。我只能使用正常填充的图标。我希望能够使用像这个例子这样的轮廓图标。

在示例中,我可以使用done_outline图标。他们是如何导入所有图标的?

在我的应用程序中,我安装了 npm install material-design-icons

我已经导入MatIconModule了我的app.module.ts但我仍然无法使用任何大纲图标。

google-material-icons angular

3
推荐指数
1
解决办法
1314
查看次数

React Native 在另一个文本组件内附加文本组件

我有一个文本组件

<Text ref="text" style{...}>{this.state.te}</Text>
Run Code Online (Sandbox Code Playgroud)

我想插入并附加其他<Text></Text>

因此,当事件在按钮上触发时,我希望它插入一个新的按钮,<Text></Text>如下所示

<Text ref="text" style{...}>
   <Text ref="text" style{...}>first</Text>
   <Text ref="text" style{...}>second</Text>
   <Text ref="text" style{...}>third</Text>
</Text>
Run Code Online (Sandbox Code Playgroud)

这就是我的活动的样子

insertText(){
 this.setState({te: this.state.te + <Text style={...}>{this.refs.newText.props.value}</Text>})
Run Code Online (Sandbox Code Playgroud)

}

当我这样做时,它呈现的所有内容都在"[object object]"文本组件内部

如果我使用

 this.setState({te: <Text style={...}>{this.refs.newText.props.value}</Text>})
Run Code Online (Sandbox Code Playgroud)

它可以用单个<Text></Text>元素很好地渲染文本。

任何帮助,将不胜感激。谢谢。

编辑:

this.state.te 持有te: <Text></Text>

javascript ios react-native

2
推荐指数
1
解决办法
1万
查看次数

JavaScript根据另一个对象数组的属性过滤对象数组

我有2个 array of objects

Tasks
[{
 name: "test",
 type: "one"
},
{
 name: "test2",
 type: 'two'
}]
Run Code Online (Sandbox Code Playgroud)

活动

[{
 name: "test",
 type: "one"
},
{
 name: "test2",
 type: 'two'
},
{
 name: "test3",
 type: "three"
 }]
Run Code Online (Sandbox Code Playgroud)

如何通过tasks数组的属性过滤活动数组?我想要这个结果.

活动

[{
 name: "test",
 type: "one"
},
{
 name: "test2",
 type: 'two'
}]
Run Code Online (Sandbox Code Playgroud)

我尝试过使用.filter(),但返回一个空集合.

let tests = activities.filter(x => tasks.includes(x.type));

我怎样才能在Javascript中实现这一目标?

javascript

1
推荐指数
1
解决办法
58
查看次数

openXmlSdk 在运行元素内插入新行

我在元素内有文本Run。我正在尝试将\r字符串中的 替换为line break

正文如下

This is an example project for testing purposes. \rThis is all sample data, none of this is real information. \r\rThis field allows for the entry of more information, a larger text field for example purposes
Run Code Online (Sandbox Code Playgroud)

innerXml元素的被Run翻译成

<w:rPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
   <w:rFonts w:cstheme="minorHAnsi" />
      </w:rPr>
        <w:t xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
           This is an example project for testing purposes.  This is all sample data, none of this is real information.&lt;w:br /&gt;&lt;w:br /&gt;This field allows …
Run Code Online (Sandbox Code Playgroud)

c# openxml-sdk

0
推荐指数
1
解决办法
2061
查看次数

如何使一系列任务按顺序运行?

我有一系列Tasks,我想从az顺序运行.

我想同步执行这些调用starting from 1 and ending at N.

  • task1 DeleteSubProjects ... 1
    • TASK1 DeleteActivities ... 2
      • TASK1 DeleteActivityPersons ... 3
      • task2 DeleteThreads ... 4
        • task1 DeleteCommunicationThreadContentTags ... 5
        • task2 DeleteCommunicationThreadParticipants ... 6
        • task3 DeleteMessages
        • task4 删除(communicationThread)
      • task3 DeleteActivityDocuments
      • task4 DeleteActivityNotes
      • task5 DeleteActivityMachines
      • task6 DeleteActivityLinks
      • task7 DeleteActivityLinks
      • task8删除(活动)
    • task2 DeleteSubProjectDocuments
    • task3 DeleteSubProjectNotes
    • task4 DeleteSubProjectPersons
    • task5 DeleteSubProjects
    • task6删除(子项目)
  • task2 deleteProjectNotes
  • task3 deleteProjectDocuments
  • task4 deleteActivities
  • task5 deleteProjectPersons

这是代码的样子

public async Task DeleteProject(Project project)
{

    var deleteSubProjects = …
Run Code Online (Sandbox Code Playgroud)

c# asynchronous task-parallel-library

-3
推荐指数
1
解决办法
62
查看次数