我正在使用EF 4.1,并且因缺乏枚举支持而寻找一个很好的解决方法.int的支持属性似乎是合乎逻辑的.
[Required]
public VenueType Type
{
get { return (VenueType) TypeId; }
set { TypeId = (int) value; }
}
private int TypeId { get; set; }
Run Code Online (Sandbox Code Playgroud)
但是,如何将此属性设为私有并仍然映射它.换一种说法:
如何首先使用EF 4.1代码映射私有属性?
我有一个应用程序,其中存在大量内存泄漏.例如,如果打开一个视图并关闭它10次,我的内存消耗量会上升,因为视图没有被完全清理掉.这些是我的内存泄漏.从测试驱动的角度来看,我想写一个测试证明我的泄漏和(在我修复了泄漏之后)声明我修复了它.这样我的代码以后就不会被破解了.简而言之:
有没有办法断言我的代码没有从单元测试中泄漏内存?
我可以做这样的事情:
objectsThatShouldNotBeThereCount = MemAssertion.GetObjects<MyView>().Count;
Assert.AreEqual(0, objectsThatShouldNotBeThereCount);
Run Code Online (Sandbox Code Playgroud)
我对分析不感兴趣.我使用Ants profiler(我很喜欢),但也想编写测试以确保'泄漏'不会回来
我正在使用C#/ Nunit,但是对于有这个哲学的人来说,我很感兴趣...
我正在为我们的产品创建一个MSI.我希望该产品能够并排安装.这样我就可以先安装1.0.0,然后再安装1.0.1,这样就可以安装两个版本了.
我正在使用WiX创建msi,并想知道如何在Wix中完成这项工作?例如
问候,Martijn
我遇到了扩展方法的奇怪的编译器错误.我有一个扩展方法的程序集
public static class MyClass
{
public static Bar GetBar(this Foo foo)
{
return new Bar();
}
}
Run Code Online (Sandbox Code Playgroud)
在同一个集会的其他地方我做这样的事情
Foo foo = new Foo();
var bar = foo.GetBar();
Run Code Online (Sandbox Code Playgroud)
当我清理和编译一切都没问题.但是,一旦我在程序集中做了一个小的更改(比如一个额外的空白)并再次构建,我得到一个像这样的错误:
错误973以下方法或属性之间的调用不明确:'MyNameSpace.MyClass.GetBar(Foo)'和'MyNameSpace.MyClass.GetBar(Foo)'
只有在我清理项目后,我才能再次构建.这是使用旧版程序集的编译器中的问题吗?我现在看到的只是解决方法是用普通的静态方法替换我的扩展方法.
我有很多代码可以用来做这样的事情
bool GetIsUnique(IEnumerable<T> values)
{
return values.Count() == values.Distinct().Count;
}
Run Code Online (Sandbox Code Playgroud)
有没有更好的更快更好的方法来做到这一点?
我在我的Windows窗体应用程序中使用bindingsource来填充我视图中的一些文本框等.绑定工作正常但是如何从我的对象中取消订阅我的bindingSource?
bindingSource.DataSource = new Foo();//OK
bindingSource.DataSource = null;//Not ok
Run Code Online (Sandbox Code Playgroud)
如果我尝试解除绑定设置data = null我得到一个例外:
System.ArgumentException:无法绑定到DataSource上的属性或列Bar.参数名称:dataMember
我不想删除所有绑定到我的控件(我有很多),但只要bindingSource没有数据就想挂起绑定....
我找到了这样的解决方法,bindingSource.DataSource = typeof(Foo);但是这样吗?
我想使用fb发送http://developers.facebook.com/docs/reference/plugins/send/按钮,但也希望预定义消息,这样用户就不必考虑说什么而只是填写收件人.可以这样做吗?如何?
我试图使用ObjectDataSource启用分页.这需要我使用SelectCountMethod(因此网格可以知道有多少页面).我的ObjectDataSource如下所示:
<asp:ObjectDataSource ID="ItemsDataSource" runat="server" SelectMethod="GetContentGridItems"
TypeName="ContentItemExtensions" SelectCountMethod="GetContentGridItemsCount" EnablePaging="True">
<SelectParameters>
<asp:QueryStringParameter Name="contentItemID" QueryStringField="cid" DbType="Guid" />
<asp:QueryStringParameter Name="contentTypeID" QueryStringField="tid" Type="String" />
<asp:QueryStringParameter Name="contentTypeGroup" QueryStringField="tgid" Type="String" />
<asp:QueryStringParameter Name="parentItemID" QueryStringField="pcid" DbType="Guid" />
<asp:QueryStringParameter Name="parentFieldID" QueryStringField="pfld" type="String" />
</SelectParameters>
Run Code Online (Sandbox Code Playgroud)
相应的静态类看起来像这样:
public static class ContentItemExtensions
{
public static DataTable GetContentGridItems(Guid? contentItemId,string contentTypeID, string contentTypeGroup, Guid? parentItemID, string parentFieldID,int maximumRows, int startRowIndex)
public static int GetContentGridItemsCount(Guid? contentItemId,string contentTypeID, string contentTypeGroup, Guid? parentItemID, string parentFieldID)
}
Run Code Online (Sandbox Code Playgroud)
当我不使用分页时,一切正常,但是当我启用分页时,我得到以下异常,清楚地说明它需要什么:
ObjectDataSource'ProjectsDataSource'找不到具有参数的非泛型方法'GetContentGridItemsCount':contentItemID,contentTypeID,contentTypeGroup,parentItemID,parentFieldID.
我的方法有这些参数,并且不是通用的,所以我没有线索.谁能帮我?
在数据集上是EnforceConstraints属性,指示是否应启用约束.虽然数据表也可以有约束我不能禁用数据表的约束.
我的情况是我有一个数据表,我在内存中使用其中一列的唯一约束.有时我想暂时禁用唯一约束.我怎样才能做到这一点?我想出的唯一一件事就是删除并重新添加约束.有没有更好的办法?
我在mvc网站上使用plupload,并希望在选择后立即上传单个文件.我将上传器控件的自动启动设置为true,但这不会激活上传.我也尝试调用uploader.start();上传者的'filesadded'委托,但这仅适用于我尝试上传的第二个文件.我在没有UI小部件的情况下使用plupload 1.4.3.2.这是我的代码:
var uploader = new plupload.Uploader({
runtimes: 'gears,html5,flash,silverlight,browserplus',
browse_button: 'pickfiles',
autostart : true,
max_file_size: '10mb',
url: '/Event/Upload',
resize: { width: 320, height: 240, quality: 90 },
flash_swf_url: '/Scripts/pl/plupload.flash.swf',
silverlight_xap_url: '/Scripts/pl/plupload.silverlight.xap',
filters: [
{ title: "Image files", extensions: "jpg,gif,png" },
{ title: "Zip files", extensions: "zip" }
]
});
uploader.bind('Init', function (up, params) {
$('#filelist')[0].innerHTML = "<div>Current runtime: " + params.runtime + "</div>";
});
uploader.bind('Error', function (up, err) {
$('#filelist').append("<div>Error: " + err.code +
", Message: " + …Run Code Online (Sandbox Code Playgroud) 我正在使用NicEdit作为我的MVC3项目中的页面的wysiwig JS编辑器.我想要一个编辑器的字段是textarea,它是一个"必需"字段.
问题是客户端JQuery验证没有"看到"在nicEdit textarea中输入的内容(因为nicEdit完全改变了页面并且textarea IS为空).我该如何解决这个问题?有没有办法用编辑框的值立即填充textarea?我可以以一种很好的方式挂钩JQuery验证,以便保持"不引人注目"吗?
谢谢
我正在为Windows Phone 7 silverlight应用程序寻找性能/ CPU分析器.像dotTrace或Ants Profiler这样的东西.有这样的事吗?
c# ×6
.net ×1
.net-3.5 ×1
build ×1
constraints ×1
datatable ×1
facebook ×1
jquery ×1
linq ×1
memory-leaks ×1
nicedit ×1
performance ×1
plupload ×1
profiling ×1
side-by-side ×1
unit-testing ×1
winforms ×1
wix ×1