它看起来像是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) 为什么下面的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) 我有一个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 ...
以前我可以使用它来获取类的泛型类型;
typeof(MyClass).GetTypeInfo().DeclaredProperties.Any(p => p.PropertyType.IsGenericType)
Run Code Online (Sandbox Code Playgroud)
但是,在DNX Core 5.0中,IsGenericType不受支持.我现在可以用什么?
我正在使用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) 谁能告诉我为什么这样有效;
<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列表...
如何访问UserManager和/或RoleManger在非托管的asp.net-5控制台应用程序包中?
我打算将我现有的ASP.NET MVC 4项目迁移到ASP.NET MVC 6,有人可以指导我或者一步一步地实现解决方案.
我试图在线找到解决方案,但大多数文章和解决方案都可用于将MVC 4迁移到MVC 5而不是MVC4到MVC6
我从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)
另外我有;
我使用的购买代码是;
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)
尽管还有其他与此问题相关的问题,但没有一个问题能为我解决。
我有一个ObservableCollection<Widget>上NotifyCollectionChangedAction.Add执行context.Widget.InsertOnSubmit(addedWidget).
在我执行之前,我context.SubmitChanges()需要删除一个已添加的项目,因为它不再需要,但是仍然可能有一些项目context.GetChangeSet().Inserts仍然需要插入.
是否可以取消特定的插入/删除而不丢弃DataContext并重新开始?
所以我有一些简单的代码可以重新调整我的配置文件图像,因为它们被消耗了,问题是,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# ×4
asp.net-core ×3
.net ×2
datagrid ×2
linq-to-sql ×2
sql-server ×2
wpf ×2
android ×1
asp.net ×1
azure-devops ×1
c#-4.0 ×1
data-binding ×1
datacontext ×1
debian ×1
dnx ×1
google-play ×1
linq ×1
mono ×1
sql ×1
styles ×1
templates ×1
windows ×1