小编Fle*_*lea的帖子

无法使用Powershell中的Get-ChildItem -Exclude参数排除目录

我正在使用Powershell v 2.0.并将文件和目录从一个位置复制到另一个位置.我使用字符串[]来过滤掉文件类型,还需要过滤掉被复制的目录.正在过滤掉文件,但是,我尝试过滤的目录obj仍在被复制.

$exclude = @('*.cs', '*.csproj', '*.pdb', 'obj')
    $items = Get-ChildItem $parentPath -Recurse -Exclude $exclude
    foreach($item in $items)
    {
        $target = Join-Path $destinationPath $item.FullName.Substring($parentPath.length)
        if( -not( $item.PSIsContainer -and (Test-Path($target))))
        {
            Copy-Item -Path $item.FullName -Destination $target
        }
    }
Run Code Online (Sandbox Code Playgroud)

我已经试过各种方法对其进行过滤,\obj*obj*\obj\ 但似乎没有任何工作.

谢谢你的帮助.

powershell powershell-2.0

24
推荐指数
3
解决办法
4万
查看次数

如何将参数传递给Entity Framework中的DbSet.SqlQuery方法

我试图在实体框架中执行一个RAW SQL语句,它接受一些参数.我使用的方法来自DbSet.SqlQuery

我对如何构造params对象数组感到困惑:params object []参数

这是我的代码块:

public ActionResult APILocation(string lat, string lng)
 {
    string SQL = "select * from (select Distance = ((ACOS(SIN(@lat * PI() / 180) * SIN(lat * PI() / 180) + COS(@lat * PI() / 180) * COS(lat * PI() / 180) * COS((@lng - Long) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) from dbo.Stores) t where  Distance < 10 order by Distance asc";
            ObjectParameter latParam = new ObjectParameter("lat", lat);
            ObjectParameter …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc entity-framework

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

如何覆盖UITableViewCell中的accessoryView来改变它的位置

默认情况下,accessoryViewUITableViewCell位于最右边的单元格.我正在UITableViewCell对它进行分类,试图改变这个位置,将它移到左边,但是,它没有效果,它仍然在右边.关于如何做到这一点的任何想法?

- (void) layoutSubviews
{
    [super layoutSubviews];
    self.accessoryView.frame = CGRectMake(100, self.accessoryView.frame.origin.y, self.accessoryView.frame.size.width, self.accessoryView.frame.size.height);
    self.accessoryView.layer.borderWidth = 1;
    self.accessoryView.layer.borderColor = [[UIColor redColor] CGColor];
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

iphone uitableview ios

8
推荐指数
2
解决办法
7076
查看次数

错误TS7027:在Angular2 TypeScript Service类中检测到无法访问的代码

我正在跟随PluralSight课程并练习在Angular2中编写基本服务.我有以下服务文件:

customer.service.ts

import { Injectable } from '@angular/core';

@Injectable()
export class CustomerService {

    constructor() {}

    getCustomers() {
        return 
        [
            {id: 1, name: 'Ward'},
            {id: 2, name: 'Joe'},
            {id: 3, name: 'Bill'},
            {id: 4, name: 'Bob'},
            {id: 5, name: 'Levi'},
            {id: 6, name: 'Brian'},
            {id: 7, name: 'Susie'}
        ];
    }
}
Run Code Online (Sandbox Code Playgroud)

当我启动lite-server使用时,npm start我收到以下错误:

angular-quickstart@1.0.0 start C:\Dev\my-proj
tsc && concurrently "tsc -w" "lite-server"

app/customer/customer.service.ts(10,3): error TS7027: Unreachable code detected.
Run Code Online (Sandbox Code Playgroud)

当我注释掉返回块时,lite-server启动正常,所以它似乎是返回它不喜欢的东西.任何帮助,将不胜感激.

node.js typescript angular

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

向Entity Framework数据库添加属性首先生成的类

我正在使用Entity Framework 4.1并使用数据库第一种方法生成我的类.我的解决方案中有一个EDMX文件.

我正在尝试使用MetadataTypeAttribute方法向我的类添加属性,这似乎是在编辑T4模板之外这样做的推荐方法,但是,我似乎无法让它工作,因为我不断收到此编译错误:

"患者"是"PatientManagementSystem.Patient"和"PatientManagementSystem.Models.Patient"之间的模糊参考.

这是我正在使用的代码:

[MetadataTypeAttribute(typeof(PatientMetadata))]
public partial class Patient
{
}

public class PatientMetadata
{

    [Required]
    public string LastName {get; set;}

}
Run Code Online (Sandbox Code Playgroud)

这个错误是否发生,因为我实际上没有这个类,因为我首先在数据库中做EDMX中的所有内容?

谢谢!跳蚤

entity-framework-4.1 asp.net-mvc-3

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

如何在 Visual Studio Code 中合并冲突

我的团队正在使用 Visual Studio Code 和 TFSVC。当我们遇到冲突时,Visual Studio 似乎给出了两个选项: Keep YoursTake Theirs. 似乎没有选项可以手动将代码实际合并在一起。我需要保持我的方法,同时也要引入我的队友方法。你如何在 Visual Studio Code 中做到这一点?

在此处输入图片说明

visual-studio-code

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

如何使用正则表达式返回前五位数

如何返回正则表达式中字符串的前5位数?

例如,如果我输入以下文本:

15203 Main Street Apartment 3 63110

我怎么能只返回"15203".

我正在使用C#.

regex

4
推荐指数
2
解决办法
5929
查看次数

将UIViews添加到cell.contentView时出现UITableView性能问题

我在使用某些子视图时遇到了性能问题UITableViewCells.在我继续滚动之后,它最终开始变得很慢.

我正在做的第一步是UIView为每个细胞创建一个共同点,基本上这是创建一个白色单元格,在带有阴影的单元格上具有圆角效果.对此的表现似乎是正常的,所以我不认为这是罪魁祸首.

在此输入图像描述

这是我用来执行此操作的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        static NSString *NewsCellIdentifer = @"NewsCellIdentifier";


       NewsItem *item = [self.newsArray objectAtIndex:indexPath.row];


            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NewsCellIdentifer];

            if (cell == nil)
            {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NewsCellIdentifer];


                cell.contentView.backgroundColor = [UIColor clearColor];

                UIView *whiteRoundedCornerView = [[UIView alloc] initWithFrame:CGRectMake(10,10,300,100)];
                whiteRoundedCornerView.backgroundColor = [UIColor whiteColor];
                whiteRoundedCornerView.layer.masksToBounds = NO;
                whiteRoundedCornerView.layer.cornerRadius = 3.0;
                whiteRoundedCornerView.layer.shadowOffset = CGSizeMake(-1, 1);
                whiteRoundedCornerView.layer.shadowOpacity = 0.5;

                [cell.contentView addSubview:whiteRoundedCornerView];
                [cell.contentView sendSubviewToBack:whiteRoundedCornerView];

                cell.layer.shouldRasterize = YES;
                cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
                cell.layer.opaque = …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview ios

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

UIButton不会拨打电话

看起来这应该很简单,但无论出于何种原因,当我按下UIButton时,我无法通过电话功能提示.

-(IBAction)viewMapButton:(id) sender
{
    NSString *phoneNumber = [[NSString alloc] initWithString:@"tel:1234567890"];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];

    NSLog(@"Call");
}
Run Code Online (Sandbox Code Playgroud)

我的NSLog被成功调用.我正在iOS模拟器上运行它; 导致它不提示拨打电话?

谢谢!跳蚤

iphone objective-c

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

REST WCF服务返回XML响应,但不返回JSON响应

我是WCF的新手,所以我认为这是非常基础的.我有一个简单的方法,返回一个"订单"对象.它在使用默认XML时工作得很好,但是,当我应用时

ResponseFormat = WebMessageFormat.Json
Run Code Online (Sandbox Code Playgroud)

属性,它无法返回JSON.代码成功执行并命中返回行,但随后立即再次调用该方法,最后在浏览器返回错误之前第三次调用,表明与localhost的连接已中断.

当我删除它时ResponseFormat = WebMessageFormat.Json,调用该方法并返回XML就好了.不确定我是否缺少JSON.

IProductSales.cs

namespace ProductsSalesService
{
    [ServiceContract(Name = "ProductsSales")]
    public interface IProductsSales
    {

        [OperationContract]
        [WebGet(UriTemplate = "Orders/{orderID}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Returns the details of an order")]
        SalesOrderHeader GetOrder(string orderID);

    }
}
Run Code Online (Sandbox Code Playgroud)

ProductSales

public SalesOrderHeader GetOrder(string orderID)
{
    SalesOrderHeader header = null;

    try
    {
        int id = Convert.ToInt32(orderID);
        AdventureWorksEntities database = new AdventureWorksEntities();

            header = (from order in database.SalesOrderHeaders
                      where order.SalesOrderID == id
                      select order).FirstOrDefault();

    }
    catch
    {
        throw …
Run Code Online (Sandbox Code Playgroud)

wcf

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