我试图创建一组自定义类来创建我自己的实体框架与之通信的提供程序.我创建了自定义类,它继承自抽象类DbProviderFactory,刚刚开始测试,看看我是否可以让它与EF交谈,但我遇到了问题.
<configuration>
<system.data>
<DbProviderFactories>
<add name="Custom Data Provider"
invariant="CustomClient"
description=".Net Framework Data Provider for Custom"
type="CustomClient.CustomProviderFactory, CustomClient,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="AdventureWorksEntities"
connectionString="metadata=...;
provider=CustomClient;
provider connection string="data source=.;
initial catalog=AdventureWorks;integrated security=True;
multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
使用上面定义的CustomClient,我认为它将顺利进入Entity goodness,但是当我的代码尝试创建一个新的AdventureWorksEntities对象时,我得到以下异常:
InvalidOperationException 请求的.Net Framework数据提供程序的实现没有System.Data.Common.DbProviderFactory派生类型的Instance字段.
查看DbProviderFactory的可用替代没有提及实例成员.我不确定为什么它需要这个字段,如果它不是DbProviderFactory的类/接口的一部分.修复是否像提供名为Instance的字段一样简单,该字段返回我的自定义类型的对象?
我一直在研究展示跨域脚本的各种示例,并遇到了我想使用jQuery.support.cors = true以及Ajax调用从Web服务检索数据的情况.我有一个使用jsonp工作的webservice的例子,我认为添加jQuery.support.cors = true很简单,将dataType更改为"json",并删除&$ callback =?来自网址.我可以看到Web服务(Netflix)带有预期数据的响应,但是当ajax调用返回时,它执行错误函数而不是成功.
我原本以为webservice可能没有合适的cors头,但我倾向于认为收到的格式化响应等同于现有的头.也许我没有正确格式化成功/错误函数,而Ajax结果不喜欢这样.
这是试图使用jQuery.support.cors无济于事的小提琴.
我对SQL很新,并且正在尝试编写一个过程来检查传入的值并设置一个本地datetime变量然后返回该变量.
USE [MyDB]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [Common].[Update_Date]
@Status_ID int
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Date_Value DATETIME
IF @Status_ID = 2
SET @Date_Value = GETDATE()
ELSE
SET @Date_Value = NULL
RETURN @Date_Value
END
GO
Run Code Online (Sandbox Code Playgroud)
当我尝试执行此脚本时,我收到以下错误:
消息257,级别16,状态3,过程Update_Date,第19行不允许从数据类型datetime到int的隐式转换.使用CONVERT函数运行此查询.
它试图用我的@Status_ID参数做些什么吗?
所以我在Html5演示中弄乱了Html5 PostMessage示例,我创建了一个示例jsfiddle,看看我是否理解它是如何协同工作的.
该演示利用了document.getElementById(...),我认为可以用jQuery选择来代替$("#..."),但我被困在因为从jQuery选择返回的对象不具有访问contentWindow而document.getElementById(...)做.
document.getElementById("frame1").contentWindow.postMessage("Hello from another domain", "http://dl.dropbox.com"); // works
$("#frame1").contentWindow.postMessage("Hello from another domain", "http://dl.dropbox.com"); // no dice
Run Code Online (Sandbox Code Playgroud)
我并不完全精通jQuery,知道从选择器调用结果对象的许多方法中的哪一个回到我将看到的结果document.getElementById(...).
所以我正在尝试动态创建控件(准确地说是RegularPolygon),并且我希望将2个PlaySoundActions添加到控件中,作为基于Tap事件的EventTrigger.目前我有以下代码:
EventTrigger trigger = new EventTrigger();
PlaySoundAction correct = new PlaySoundAction();
PlaySoundAction incorrect = new PlaySoundAction();
correct.Source = new Uri("/Sounds/Correct.mp3");
correct.Volume = 0.5;
incorrect.Source = new Uri("/Sounds/Incorrect.mp3");
incorrect.Volume = 0.5;
trigger.Actions.Add(correct); // this line doesn't work
trigger.Actions.Add(incorrect); // this also doesn't work
shape.Triggers.Add(trigger);
Run Code Online (Sandbox Code Playgroud)
每行都有一个错误
错误2参数1:无法从'Microsoft.Expression.Interactivity.Media.PlaySoundAction'转换为'System.Windows.TriggerAction'
我不完全确定将PlaySoundAction对象强制转换为什么.我不想在XAML中这样做,因为我正在动态创建这些控件.
我还尝试为RegularPolygon创建一个Style,使EventTrigger具有PlaySoundAction,但是以编程方式设置控件的样式不会将此逻辑添加到控件中.
<Application.Resources>
<ResourceDictionary>
<Style TargetType="es:RegularPolygon" x:Key="Default">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap">
<eim:PlaySoundAction Source="/Sounds/Incorrect.mp3" Volume="0.5" />
<eim:PlaySoundAction Source="/Sounds/Correct.mp3" Volume="0.5" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Style>
</ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
有没有办法在代码中添加EventTrigger/PlaySoundAction或创建一个控件可以继承的样式,具有EventTrigger/PlaySoundAction?
我试图以一种方式使用linq来避免在DataSet中对DataRows做一个foreach:
var results = from dataRow in DataRows
let MoreData = func(dataRow.ID)
join moreDataRow in MoreData on dataRow.ID2 = moreDataRow.ID2
select new
{
ID1 = dataRow.ID,
ID2 = dataRow.ID2,
ID3 = dataRow2.ID3
};
Run Code Online (Sandbox Code Playgroud)
我想完成类似上面的操作,但是linq不能将MoreData用作join语句的一部分.如果我无法做到这一点,我可能会在DataRows上做一个foreach并从那里开始.
是否有一种连接数据的linqy方法,在迭代元素然后执行从原始数据到新生成的数据的连接之前,这些数据是不可用的?
c# ×2
javascript ×2
jquery ×2
ado.net ×1
dom ×1
html5 ×1
jsonp ×1
linq ×1
silverlight ×1
sql ×1