小编Sta*_*ams的帖子

在Windows和Linux上dnxcore50有什么区别?

它看起来像是System.Data.SqlClient在Windows上运行时在dnxcore50中定义的,而不是在Linux上运行的.

它们不是corefx吗?

例如,一个针对dnxcore50 beta7或beta8的应用程序和引用System.Data.SqlClient将在Windows中构建并运行良好,但在Linux上只能在执行时编译正常运行此运行时错误;

An unhandled exception has occurred: Could not load file or assembly 
'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 
The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)

asp.net-core

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

DataGridCell.Template样式覆盖IsSelected触发器

为什么下面的IsSelected Trigger仅在代码中没有Template Setter时才起作用?如何使两者都按预期运行?

我在Application.Resources标签中有以下内容;

<Style TargetType="{x:Type DataGridCell}">
    <Style.Triggers>
        <Trigger Property="IsSelected" Value="True">
            <Setter Property="Background" Value="Red"/>
        </Trigger>
    </Style.Triggers>

    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type DataGridCell}">
                <ContentPresenter VerticalAlignment="Center"></ContentPresenter>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

wpf datagrid templates styles

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

linq vs sql(或.NET app vs SQL Server管理工作室)

我有一个linq查询,它根据id列(其中id = @id)从View中检索行

此查询需要4秒才能运行.我已经使用SQL Server Profiler来检查由linq执行的查询,如果我将该查询直接复制到管理工作室并执行,则查询只需要56ms.

在我的应用程序中,所有linq查询与视图的指数时间增加是一致的.当相同的查询执行<100ms时,在我的(WPF)应用程序中可能导致延长执行时间的原因是什么?

==编辑==

我已经设法进一步隔离,评论显示剖析器持续时间;

/* 3953ms, 111487 reads */
context.SkuView.Where(p => p.TermId == 35 && !p.IsDeleted).ToList(); 

/* 90ms, 173 reads */
context.SkuView.Where(p => p.TermId == 35).ToList(); 
Run Code Online (Sandbox Code Playgroud)

如果我将(sql呈现的)linq查询直接粘贴到ssms我得到;

/* 250ms, 173 reads */
SELECT * FROM SkuView WHERE TermId == 35 AND IsDeleted = 0

/* 250ms, 173 reads */
SELECT * FROM SkuView WHERE TermId == 35
Run Code Online (Sandbox Code Playgroud)

所以问题与使用时通过linq读取计数有关!p.IsDeleted ...

.net sql sql-server linq-to-sql

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

如何确定属性是否为DNX Core 5.0中的通用类型?

以前我可以使用它来获取类的泛型类型;

typeof(MyClass).GetTypeInfo().DeclaredProperties.Any(p => p.PropertyType.IsGenericType)
Run Code Online (Sandbox Code Playgroud)

但是,在DNX Core 5.0中,IsGenericType不受支持.我现在可以用什么?

.net c# dnx asp.net-core

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

实体框架7无法插入日期时间

我正在使用EntityFramework 7,beta7并具有以下实体:

C#

public class Log
{
    [Column(TypeName ="datetime")]
    public DateTime Date { get; set; }
    ...
}
Run Code Online (Sandbox Code Playgroud)

SQL

CREATE TABLE [dbo].[Logs] (
    [Date] [datetime] NOT NULL,
    ...
)
Run Code Online (Sandbox Code Playgroud)

我执行以下操作:

db.Logs.Add(new Log { Date = DateTime.UtcNow });
db.SaveChanges();
Run Code Online (Sandbox Code Playgroud)

这在Windows上是成功的,但在debian上的mono下失败了.相同的SQL服务器/数据库.生成的SQL如下.请注意为@p1以下内容呈现的类型和值的差异:

视窗

exec sp_executesql N'SET NOCOUNT OFF;
INSERT INTO [Logs] ([Browser], [Date], [Exception], [HostAddress], [Level], [Logger], [Message], [Thread], [Url], [Username])
OUTPUT INSERTED.[Id]
VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9);
',N'@p0 nvarchar(max) ,@p1 datetime2(7),@p2 nvarchar(max) ,@p3 nvarchar(max) …
Run Code Online (Sandbox Code Playgroud)

windows sql-server mono debian entity-framework-core

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

WPF Datagrid ComboBox DataBinding

谁能告诉我为什么这样有效;

<DataGridTemplateColumn Header="Supplier">
  <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
          <ComboBox DisplayMemberPath="SupplierName" SelectedValuePath="SupplierID" 
                    SelectedValue="{Binding SupplierID}"
                    ItemsSource="{Binding Path=DataContext.Suppliers, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" />
      </DataTemplate>
  </DataGridTemplateColumn.CellTemplate>
Run Code Online (Sandbox Code Playgroud)

但这不;

<DataGridComboBoxColumn Header="Combo" DisplayMemberPath="SupplierName" SelectedValuePath="SupplierID" 
  SelectedValueBinding="{Binding SupplierID}"
  ItemsSource="{Binding Path=DataContext.Suppliers, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" />
Run Code Online (Sandbox Code Playgroud)

第二个片段在编辑时不显示SupplierName列表...

data-binding wpf datagrid datagridcomboboxcolumn

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

如何从Console App访问UserManager和RoleManager?

如何访问UserManager和/或RoleManger在非托管的控制台应用程序包中?

c# asp.net entity-framework-core asp.net-core

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

对于MVC6 RC1,现有的MVC项目是否有简单的升级过程?

我打算将我现有的ASP.NET MVC 4项目迁移到ASP.NET MVC 6,有人可以指导我或者一步一步地实现解决方案.

我试图在线找到解决方案,但大多数文章和解决方案都可用于将MVC 4迁移到MVC 5而不是MVC4到MVC6

asp.net-mvc-4 asp.net-core-mvc

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

GooglePlay:您所请求的商品无法购买

我从Google Play IAB API获得以下信息;

您请求的商品无法购买

但是,我已经针对静态响应成功进行了测试,此外,以下代码myProductId在可用产品列表中返回;

ArrayList<String> skuList = new ArrayList<String> ();
skuList.add("myProductId");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
Bundle skuDetails = service.getSkuDetails(3, activity.getPackageName(), "inapp", querySkus);
Run Code Online (Sandbox Code Playgroud)

另外我有;

  • 发布了Beta版APK
  • 将测试用户添加到Beta中,并通过URL选择加入
  • 使用测试用户(Gmail帐户)登录设备
  • 将具有相同版本代码的签名APK推送到设备
  • 激活了产品

我使用的购买代码是;

Bundle buyIntentBundle = service.getBuyIntent(3, activity.getPackageName(), "myProductId", "inapp", "payload");
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
activity.startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
Run Code Online (Sandbox Code Playgroud)

最后,logcat显示以下内容;

ArrayList<String> skuList = new ArrayList<String> ();
skuList.add("myProductId");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
Bundle skuDetails = service.getSkuDetails(3, activity.getPackageName(), "inapp", querySkus);
Run Code Online (Sandbox Code Playgroud)

尽管还有其他与此问题相关的问题,但没有一个问题能为我解决。

  1. 您要求的商品无法购买
    • 产品有效 …

android in-app-purchase in-app-billing google-play

3
推荐指数
2
解决办法
7011
查看次数

默认“合并后完成链接的工作项”为未选中

VSTS 中出现了 PR 完成的新功能,其中默认标记为完成的 PR 也会将链接的工作项标记为完成,除非未选中。

如果可能错过此复选框,是否可以将其默认为未选中?

完整的公关对话

azure-devops

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

从ChangeSet中删除Linq-to-SQL

我有一个ObservableCollection<Widget>上NotifyCollectionChangedAction.Add执行context.Widget.InsertOnSubmit(addedWidget).

在我执行之前,我context.SubmitChanges()需要删除一个已添加的项目,因为它不再需要,但是仍然可能有一些项目context.GetChangeSet().Inserts仍然需要插入.

是否可以取消特定的插入/删除而不丢弃DataContext并重新开始?

c# linq datacontext linq-to-sql

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

C#图像调整数学问题

所以我有一些简单的代码可以重新调整我的配置文件图像,因为它们被消耗了,问题是,C#代码没有按照我的预期运行...

这里是索引视图的Controller Action Method里面的一些代码,我在这里做...

    string fullFileName = HttpContext.Server.MapPath(profile.ProfilePhotoPath);
    System.Drawing.Image img = System.Drawing.Image.FromFile(fullFileName);
    int width = img.Width;
    int height = img.Height;

    float reductionPercentage = 0F;

    if (width >= height)
    {
        reductionPercentage = (282 / width);
    }
    if (width < height)
    {
        reductionPercentage = (337 / height);
    }

    int newWidth = (int)Math.Round(width * reductionPercentage);
    int newHeight = (int)Math.Round(height * reductionPercentage);

    ViewBag.newWidth = newWidth;
    ViewBag.newHeight = newHeight;
Run Code Online (Sandbox Code Playgroud)

除非达到"reductionPercentage = * " ,否则它的每个部分都能完美运行

如果图像尺寸较小或相同,则reducePercentage完全按照预期的方式进行,并将值1指定给reductionPercentage,但是,如果图像较大,则表示它根本不进行数学计算,它总是吐出0作为reductionPercentage的值...

任何想法,我可能做错了什么?

c# c#-4.0

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