摘要: 1. 接口为ExecuteStoredProcedure(string storedProcedureName, params ObjectParameter[] parameters) 2. 参数为存储过程名字, 及输入值。 3. 思路:创建连接(连接中指定了是Sql/MySql/ODBC等等); 创建通用DbCommand;更改Text以及Type;添加通用Parameter(DBPara... 阅读全文
posted @ 2013-07-03 16:48 muzizongheng 阅读(1005) 评论(0) 推荐(0) 编辑
摘要: xml schema中有hexBinary类型, 我们在实现C#的Serialization时,一般默认把hexBinary映射为byte[],但是有些情况我们需要把 hexBinary映射为uint、int等等这样的类型。 这样我们就需要包装下, 如下: xml schema中定义ID节点, 类型为hexBinary。我们通过中间byte[] IDBinary转为uint ID, 实际使用中直... 阅读全文
posted @ 2013-07-03 16:48 muzizongheng 阅读(453) 评论(0) 推荐(0) 编辑
摘要: Entity Framework的性能优化: 1.使用MergeOption.NoTracking(发现添加这个代码后, 导致"The object cannot be deleted because it was not found in the ObjectStateManager."错误,解决办法为, 先调用entity实例的Attach(deleteObj),参数为要删除的对象,然后调用... 阅读全文
posted @ 2013-07-03 16:47 muzizongheng 阅读(571) 评论(0) 推荐(0) 编辑
摘要: 1. 用Html.BeginForm(ActionName,ControllerName,Post)来实现controller-action的路由, 2. Form里的每个input的name值统一,比如都命名为commandName, 每个input的value设为不同值。3. 更改Action处理方法的参数, 添加一个参数为commandName,则commandName的值为input设置... 阅读全文
posted @ 2013-07-03 16:47 muzizongheng 阅读(715) 评论(0) 推荐(0) 编辑
摘要: 其中Customers为数据库的某个表名,Custom自动被默认为单条记录的对象, 利用构造,InsertOnSubmit, 以及SubmitChanges实现插入数据。注意:linqpad的language选择为C# Statement(s)Customer cust = new Customer { ID=1000, Name="Bloggs" };Customers.InsertOnSubm... 阅读全文
posted @ 2013-07-03 16:46 muzizongheng 阅读(488) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2013-07-03 16:13 muzizongheng 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 项目中遇到一个问题, 有4张表, 然后相互之间有3张关系表关联, 一共七张表。 想要从顶层表查询最底层表的记录,不能写7层嵌套。 用Linq实现特别简单,表:User,Role,Module,Function以及User_Role,Role_Module, Module_Function, var fs = (from r in DB.user_role ... 阅读全文
posted @ 2013-07-03 16:11 muzizongheng 阅读(558) 评论(0) 推荐(0) 编辑
摘要: 添加ExpectedException属性, 然后指定异常类型, catch后决定Assert.IsTrueThe following class contains the method to test:C#VBusing System; namespace MyCSNamespace { public class DivisionClass { public ... 阅读全文
posted @ 2013-07-03 15:05 muzizongheng 阅读(1136) 评论(0) 推荐(0) 编辑
摘要: TextBox txtTest;System.Windows.Input.InputMethod.SetIsInputMethodEnabled(txtTest, false); 阅读全文
posted @ 2013-07-03 14:35 muzizongheng 阅读(405) 评论(0) 推荐(0) 编辑
摘要: private void SetEnglishInputLanguage() { _inputLanguageBackup = System.Windows.Forms.InputLanguage.CurrentInputLanguage; System.Windows.Forms.InputLanguage.Cur... 阅读全文
posted @ 2013-07-03 14:34 muzizongheng 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 1.针对整个ContextMenu, 自定义一个Style,去掉竖分割线 ... 阅读全文
posted @ 2013-07-03 14:33 muzizongheng 阅读(647) 评论(0) 推荐(0) 编辑
摘要: 主要是针对DataGridCellsPresenter而不是SelectiveScrollingGrid,使用时DataGridRow应用这个style就可以了。 阅读全文
posted @ 2013-07-03 14:32 muzizongheng 阅读(471) 评论(0) 推荐(0) 编辑
摘要: System.Windows.Interactivity.Interaction.GetTriggers(sender as DependencyObject)[0].Actions 阅读全文
posted @ 2013-07-03 14:31 muzizongheng 阅读(370) 评论(0) 推荐(0) 编辑
摘要: 今天调试自己写的WPF的Behavior, 是关于TextBox只能输入数据或者小数点的。 发现有个问题, 就是英文IME下字母等等都能过滤, 但是一旦切换到中文输入法, 就会发现在OnPreviewTextInput处理 时Textbox.Text已经得到中文输入的值,导致就算PreviewTextInput响应了,而且当前的中文也被过滤了,但是TextBox.Text已经有同样的中文存在,... 阅读全文
posted @ 2013-07-03 14:30 muzizongheng 阅读(1527) 评论(0) 推荐(0) 编辑
摘要: Datagrid或者listview 中想要把相应的项 滚动到当前可见的位置, 必须满足2个条件: 1) 必须去掉虚拟化 VirtualizingStackPanel.IsVirtualizing ="False"2) 调用ScrollToView //Bring current selected item to view if(null != grdStudyList. Selected... 阅读全文
posted @ 2013-07-03 14:29 muzizongheng 阅读(635) 评论(0) 推荐(0) 编辑
摘要: Datagrid有多个bug;1,不支持DynamicResource的东西2, 在Column隐藏后再显示, ColumnHeader的Tag或者DataContext为null。解决办法:用StaticResource ,如下面的StaticResourceDGC_ContentTemplate;用DataGridColumnHeader的Column,来取得上层的datacontext。如,... 阅读全文
posted @ 2013-07-03 14:27 muzizongheng 阅读(353) 评论(0) 推荐(0) 编辑
摘要: using System ;using System .Diagnostics;using System .IO;class Program{ static void Main() { // // Setup the process with the ProcessStartInfo class. ... 阅读全文
posted @ 2013-07-03 11:42 muzizongheng 阅读(1523) 评论(0) 推荐(0) 编辑
摘要: Collection was modified; enumeration operation may not execute”这次项目中遇到一个问题, 就是C#程序随机崩溃, 抛出上面的异常。经过debug后,发现原因是:c#的linq用Where关键字查询列表时,其他线程在操作此列表, 导致Where查询转换为Foreach时抛出异常。解决办法: 应该有个全局的信号量来负责同步对列表的操作。 在... 阅读全文
posted @ 2013-07-03 11:41 muzizongheng 阅读(498) 评论(0) 推荐(0) 编辑
摘要: 现在我们同时在主干和分支上进行开发, 当你需要将主干上某一工程代码 Merge到分支上(或者相反)时, 不要用check out 然后全部覆盖的方法, 这样不会关联源上的任何 history, 而且需要对每个被覆盖的文件进行比较。正确操作如下图:好处是:一是以前的 history还在, 二是Merge时 TFS也会提示到底哪些改动了。 阅读全文
posted @ 2013-07-03 11:40 muzizongheng 阅读(300) 评论(0) 推荐(0) 编辑
摘要: 以下的这个类实现了 2个含有部分字段名字相同 的对象的 赋值拷贝。public class ShallowCopyHelper { public static void CopyPropertiesValue(object objFrom, object objTo) { if (null == objFrom) { return; } if (null == objTo) { return;... 阅读全文
posted @ 2013-07-03 11:39 muzizongheng 阅读(346) 评论(0) 推荐(0) 编辑
摘要: @Echo Off Set _Date=%date% If "%_Date%A" LSS "A" (Set _NumTok=1-3) Else (Set _NumTok=2-4) :: Default Delimiter of TAB and Space are used For /F "TOKENS=2*" %%A In ('REG QUERY "HKCU\Control Panel\Inte... 阅读全文
posted @ 2013-07-03 11:38 muzizongheng 阅读(1037) 评论(0) 推荐(0) 编辑
摘要: 1,更改任何文件, 先checkout, 再继续更改。2. 更新sln时, 一定要更新include文件3. 每次提交代码放到shelf上, 自己本地建立2个workspace, 来进行codereview, 完成后让龙海进行测试。 一定要告诉龙海影响了哪些功能, 需要不需要进行完整的回归测试。4. 解决bug时, 应该关联changeset。Template when solve a DIM b... 阅读全文
posted @ 2013-07-03 11:15 muzizongheng 阅读(564) 评论(2) 推荐(0) 编辑
摘要: 1. 首先到官网下载http://threadpool.sourceforge.net/2. 包含头文件#include "../boost/threadpool.hpp"3. 声明threadpool对象,boost::threadpool::fifo_pool m_poolCmdProcess;上面声明了一个FIFO线程池, 即先进先出4. 声明一个Runnable适配类 来包装你的类及成员函... 阅读全文
posted @ 2013-07-03 11:13 muzizongheng 阅读(753) 评论(0) 推荐(0) 编辑
摘要: 1. 首先引用boost::function和boost::bind的头文件和库;#include "boost/bind.hpp"#include "boost/function.hpp" 2. 声明自己的function模板typedef boost::function CMDHANDLER;3. 写出自己类及成员函数class CCommunicationMap{public:CComm... 阅读全文
posted @ 2013-07-03 11:12 muzizongheng 阅读(1346) 评论(0) 推荐(0) 编辑
摘要: 最近做一个ListView的Style时,发现一个问题, 就是我的GridView的GridViewColumn的CellTemplate无论是用StaticResource还是DynamicResource,都是没有效果。原因:GridViewColumn用了DisplayMemberBinding 使得CellTemplate失效。解决办法: 去掉DisplayMemberBinding, ... 阅读全文
posted @ 2013-07-03 11:11 muzizongheng 阅读(826) 评论(0) 推荐(0) 编辑
摘要: 最近做WPF项目遇到一个问题, 我有2个process, 一个Process里只有Usercontrol, 另一个Process获取前一个Process中Usercontrol并host到当前的window里。 结果Usercontrol里的ErrorTemplate默认的红框没有出现, 但是ValidationRule已经触发。 原因找见: Window类默认的Style包含AdornerDe... 阅读全文
posted @ 2013-07-03 11:10 muzizongheng 阅读(433) 评论(0) 推荐(0) 编辑
摘要: WPF error: does not contain a static 'Main' method suitable for an entry pointdoes not contain a static 'Main' method suitable for an entry point在Visual Studio中删除App.xaml从别的位置拷贝一个后会出现的编译错误,原因在于默认的App.... 阅读全文
posted @ 2013-07-03 11:08 muzizongheng 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 'System.Collections.Generic.IEnumerable' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be ... 阅读全文
posted @ 2013-07-03 11:06 muzizongheng 阅读(829) 评论(0) 推荐(0) 编辑
摘要: 以下是一个包装的用于序列化反序列化XML和C# 对象的类。public class XmlSerializeHelper { #region Serialize/Deserialize private static System.Xml.Serialization.XmlSerializer serializer; private static System.Xml.Serialization.X... 阅读全文
posted @ 2013-07-03 11:04 muzizongheng 阅读(497) 评论(0) 推荐(0) 编辑
摘要: 以下方法实现了遍历一个class中所有的字段, 并且递归遍历sub class。private StringBuilder _properties = new StringBuilder(); public MainView() { TraversalProperties(typeof(StudyInfoModel)); File.WriteAllText("Properties.txt", _... 阅读全文
posted @ 2013-07-03 11:02 muzizongheng 阅读(578) 评论(0) 推荐(0) 编辑
摘要: 今天遇到一个很火的问题, 一个c#的class 序列化成xml后抛出异常, 信息为: XmlSerialize error: There was an error generating the XML document.然后看了下异常的内部原因, 是一个类型不匹配的问题, 把X转为Y的序列化。 阅读全文
posted @ 2013-07-03 10:28 muzizongheng 阅读(535) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2013-07-02 17:42 muzizongheng 阅读(158) 评论(0) 推荐(0) 编辑
摘要: No overload for 'OnStartup' matches delegate 'System.Windows.StartupEventHandler' 今天wpf工程的App.xaml爆出这个问题, 明明cs理由事件处理函数OnStartUp,却无法编译。原因是App.xaml声明的类名和App.xaml.cs中的类名不同。修改一直, 并确认Event Hanlder存在。 阅读全文
posted @ 2013-07-02 17:40 muzizongheng 阅读(971) 评论(0) 推荐(0) 编辑
摘要: Linq 支持动态字查询集合, 也就是说根据传入的值进行查询。 比如我们有个类Patient, 其中有个字段PatientName, 现在有Patient集合, 想要查询PatientName为“John”的。 代码如下:class Patient{public string PatientName = "";}List patients = new List;Patient p1 = new ... 阅读全文
posted @ 2013-07-02 17:34 muzizongheng 阅读(320) 评论(0) 推荐(0) 编辑
摘要: 1. arrayValue 和 vector的转换 // Json::Value root; vectorm_vctProcedureUID;for(std::vector::iterator iter = m_vctProcedureUID.begin(); iter!=m_vctProcedureUID.end(); iter++){root... 阅读全文
posted @ 2013-07-02 16:54 muzizongheng 阅读(301) 评论(0) 推荐(0) 编辑
摘要: #include #ifdef _UNICODE#define tstring std::wstring#define __T(quote) L##quote#else#define tstring string#define __T(quote) quote#endif#define _T(quote) __T(quote)#define _TEXT(quote) __T(quote)#defi... 阅读全文
posted @ 2013-07-02 16:50 muzizongheng 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 比如namespace A, 内部Class A, 那么调用class A的方法只能通过A.A.XXX来访问。 或者说实例化一个class A,A a = new A(); // compile errorA a = new A.A(); //Ok 阅读全文
posted @ 2013-07-02 16:38 muzizongheng 阅读(250) 评论(0) 推荐(0) 编辑
摘要: Visual Studio 编译后去掉只读属性attrib $(TargetPath) -Rattrib $(TargetDir)$(TargetName).pdb -R 阅读全文
posted @ 2013-07-02 16:37 muzizongheng 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 火车票提前11天电话95105105订票流程~预知步骤节省时间2011-09-18 14:42:31 根据语音提示选择, 电话接通,一长串通知,可按任意键跳过; 一、订票---1, 订单查询/取消---2, (3没听清) 二、承接上一步“订票”, 又一波长串通知,可按任意键跳过 订票须知---1, 动车/直达车/高铁---2,普通车次---4, 学生票---6, 不限车次---... 阅读全文
posted @ 2013-07-02 16:36 muzizongheng 阅读(262) 评论(0) 推荐(0) 编辑
摘要: The following module was built either with optimizations enabled or without debug information今天同事的项目在Debug时遇到一个问题,添加断点,提示:断点在当前文本无效,给调试同昨带来一个问题,经研究发现,这个与Debug的模式有关。前提:VS2005 sp1,Debug模式。运行时提示如下信息:根... 阅读全文
posted @ 2013-07-02 16:35 muzizongheng 阅读(351) 评论(0) 推荐(0) 编辑
如果我们时时忙着展现自己的知识, 将何从忆起成长所需的无知?