如果我有LINQ对象:
public class SampleDataContext : DataContext {
public Table<Customer> Customers { get { return this.GetTable<Customer>(); } }
public SampleDataContext( string connectionString ) : base( connectionString ) { }
}
[Table( Name="dbo.tblCustomers" )]
public class Customer {
private Guid? customerID;
[Column( Storage="customerID", DbType="uniqueidentifier NOT NULL", IsPrimaryKey=true )]
public Guid? CustomerID {
get { return this.customerID; }
set { this.customerID = value; }
}
private string customerName;
[Column( Storage = "customerName", DbType = "nvarchar(255) NOT NULL" )]
public string CustomerName {
get …Run Code Online (Sandbox Code Playgroud) 我想使用宏来发布我的webapplication项目.小问题是,DTE.ExecuteCommand异步运行,我需要等到命令完成.
例:
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("04 - Products\04 - Products.WSS").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Publish")
'// now I want copy (and overwrite) some files, but AFTER the publish
Run Code Online (Sandbox Code Playgroud)
是否有一些同步对象或有关已执行命令状态的信息?
谢谢
有没有人有.NET Reflector Pro(不是免费版)的经验?
我已经搜索了一些在外部环境中轻松调试应用程序的方法(例如,不在办公室的生产服务器),我找到了.NET Reflector Pro及其功能"步入反编译程序集并使用所有调试技术会使用你自己的代码".
它看起来非常有用,但我想听听有关该工具的个人经验......特别是那些"每天"使用它的人.
谢谢!
编辑: 一些额外的信息:我想使用此功能来模拟模块化应用程序的旧版本(多个版本中的100多个模块),以便难以重现未在测试环境中显示的错误(例如组合数据库中的数据,服务器/客户端的当前配置等.
有一种方法可以重建指定的程序集(有时需要几十个程序集)...添加一些特定于问题的日志记录信息.但是,它需要很长时间,而不是轻松调试和查看局部变量,字段,线程等内容.
有没有办法如何从Lambda表达式获取名称ov事件,如与属性( 从lambda表达式检索属性名称)?
谢谢
我需要一些属性类中的Guid属性,如下所示:
public class SomeAttribute : Attribute {
private Guid foreignIdentificator;
public Guid ForeignIdentificator {
get { return this.foreignIdentificator; }
set { this.foreignIdentificator = value; }
}
}
Run Code Online (Sandbox Code Playgroud)
但是在属性定义中,我只能使用原始类型,它们是常量(我理解为什么,这让我有意义).解决方法可以将"ForeignIdentificator"定义为字符串,并在运行时创建Guid:
public class SomeAttribute : Attribute {
private string foreignIdentificator;
public string ForeignIdentificator {
get { return this.foreignIdentificator; }
set { this.foreignIdentificator = value; }
}
public Guid ForeignIdentificatorGuid {
get { return new Guid( ForeignIdentificator ); }
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我没有检查类型安全性."ForeignIdentificator"属性可以包含任何字符串值,并且在创建过程中Guid将在运行时抛出异常,而不是在编译时抛出异常.
我知道编译器检查"System.Runtime.InteropServices.GuidAttribute"的字符串值是否为"Guid兼容性".这个检查正是我需要的,但我不知道这个检查是否在编译器中硬编码或者我可以明确定义(以及如何).
你知道某种方式,如何确保"Guid compatibilitybilty"检查属性?或者另一种方式,如何在属性中达到类型安全的Guid定义?谢谢.
是否有一些有效的方法如何在"varbinary(max)filestream"列中获取数据长度?我发现只有转换为varchar的样本然后调用"LEN"函数.
有没有办法,如何获得当前抛出的异常(如果存在)?
我想减少代码量并对任务应用一些重用,如下所示:
Exception thrownException = null;
try {
// some code with 3rd party classes, which can throw unexpected exceptions
}
catch( Exception exc ) {
thrownException = exc;
LogException( exc );
}
finally {
if ( null == thrownException ) {
// some code
}
else {
// some code
}
}
Run Code Online (Sandbox Code Playgroud)
并用以下代码替换它:
using( ExceptionHelper.LogException() ) {
// some code with 3rd party classes, which can throw unexpected exceptions
}
using( new ExceptionHelper { ExceptionAction = ()=> /*some cleaning …Run Code Online (Sandbox Code Playgroud) 我正在使用PropertyGrid控件来编辑应用程序中的某些对象.我正在使用自定义TypeConverters和TypeEditors来获得更好的用户界面.
我对自定义TypeConverter的布尔属性有问题.如果我有这个课程:
public class MyClass {
public string Name { get; set; }
[System.ComponentModel.TypeConverter( typeof( BoolTypeConverter ) )]
public bool Flag { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我在PropertyGrid中创建实例并将其设置为SelectedObject - 一切正常,直到用户在属性网格项上的DoubleClicked形成"Flag"属性.在DoubleClick发出此消息后:alt text http://tcks.wz.cz/property_grid_error.PNG
TypeConverter类看起来:
public class BoolTypeConverter : System.ComponentModel.TypeConverter {
public const string TEXT_TRUE = "On";
public const string TEXT_FALSE = "Off";
public const string TEXT_NONE = "< none >";
public override object CreateInstance( System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues ) {
object ret = base.CreateInstance( context, propertyValues );
return ret;
}
public …Run Code Online (Sandbox Code Playgroud) 我创建了带有网格的表单来可视化任何集合(ICollection,ICollection<T>)对象.
之后我创建了调试器可视化器类(继承自Microsoft.VisualStudio.DebuggerVisualizers.DialogDebuggerVisualizer).
可视化器是安装的(我在System.Collections.ArrayList课堂上试过).
但是我将可视化器概括为任何ICollection/ ICollection<T>类型都有问题.
我指定了属性:
[assembly: DebuggerVisualizer( typeof( DebugerSide ), typeof( VisualizerObjectSource ), Target = typeof( System.Collections.Generic.ICollection<> ), Description = "Collection visualizer" )]
[assembly: DebuggerVisualizer( typeof( DebugerSide ), typeof( VisualizerObjectSource ), Target = typeof( System.Collections.ICollection ), Description = "Collection visualizer" )]
Run Code Online (Sandbox Code Playgroud)
但VS在调试中不提供可视化工具.
如果我指定了exactl类名,则可视化器在VS中可用.有办法,如何表达我的意图还是没有办法,如何实现呢?
谢谢!
"最佳实践"之一是通过存储过程访问数据.我明白为什么这种情况很好.我的动机是拆分数据库和应用程序逻辑(表可以改变,如果存储过程的行为相同),SQL注入的防御(用户不能执行"select*from some_tables",他们只能调用存储过程),以及安全性(在存储过程中可以是"任何"安全的,用户不能选择/插入/更新/删除数据,这不适合他们).
我不知道的是如何使用动态过滤器访问数据.
我正在使用MSSQL 2005.
如果我有桌子:
CREATE TABLE tblProduct (
ProductID uniqueidentifier -- PK
, IDProductType uniqueidentifier -- FK to another table
, ProductName nvarchar(255) -- name of product
, ProductCode nvarchar(50) -- code of product for quick search
, Weight decimal(18,4)
, Volume decimal(18,4)
)
Run Code Online (Sandbox Code Playgroud)
然后我应该创建4个存储过程(创建/读取/更新/删除).
"创建"的存储过程很简单.
CREATE PROC Insert_Product ( @ProductID uniqueidentifier, @IDProductType uniqueidentifier, ... etc ... ) AS BEGIN
INSERT INTO tblProduct ( ProductID, IDProductType, ... etc .. ) VALUES ( @ProductID, @IDProductType, ... etc ... ) …Run Code Online (Sandbox Code Playgroud) .net ×4
c# ×4
debugging ×2
attributes ×1
automation ×1
c#-3.0 ×1
crud ×1
datacontext ×1
datalength ×1
envdte ×1
filestream ×1
finally ×1
guid ×1
lambda ×1
linq-to-sql ×1
macros ×1
propertygrid ×1
reflector ×1
sql ×1
sql-server ×1
varbinary ×1
winforms ×1