c#-4.0

How often should I open/close my Booksleeve connection?

自古美人都是妖i 提交于 2020-01-22 13:23:23
问题 I'm using the Booksleeve library in a C#/ASP.NET 4 application. Currently the RedisConnection object is a static object across my MonoLink class. Should I be keeping this connection open, or should I be open/closing it after each query/transaction (as I'm doing now)? Just slightly confused. Here's how I'm using it, as of now: public static MonoLink CreateMonolink(string URL) { redis.Open(); var transaction = redis.CreateTransaction(); string Key = null; try { var IncrementTask = transaction

getting duplicate rows for each row using linq query

≯℡__Kan透↙ 提交于 2020-01-22 03:18:45
问题 I have db schema having tables like this below, i am trying to get the results using left join or normal join on these table using the below query. Somehow getting duplicate rows like as mentioned below. Requests (table) RequestStage (table) ------------- ---------------- id RequestStageid createdAt(datetime) name (values: RequestSubmitted,Inreview) RequestTypeId MasterSectionID RequestStatusID RequestStageID id (FK)(localCodes) MasterSections (table) ------------------------- MasterSectionId

80040111 ClassFactory cannot supply requested class (Exception from HRESULT: 0x80040111 (CLASS_E_CLASSNOTAVAILABLE))

五迷三道 提交于 2020-01-21 14:40:51
问题 Retrieving the COM class factory for component with CLSID {0A80A563-28AE-11D3-9CD6-00C04F8B8EF1} failed due to the following error: 80040111 ClassFactory cannot supply requested class (Exception from HRESULT: 0x80040111 (CLASS_E_CLASSNOTAVAILABLE)) I've Searched for the entry in Registry I can Find Assembly with {0A80A563-28AE-11D3-9CD6-00C04F8B8EF1} at HKLM\Software\Classes\Wow6432Node\CLSID{0A80A563-28AE-11D3-9CD6-00C04F8B8EF1}\InProcServer32 I've Created Application By using embedded

Regex - Capturing a Repeated Group

旧巷老猫 提交于 2020-01-21 10:10:31
问题 Alright, I've read the tutorials and scrambled my head too much to be able to see clearly now. I'm trying to capture parameters and their type info from a function signature. So given a signature like this: function(/*string*/a,b,c) I want to get the parts like this: type: string param:a param:b param:c This is Ok too: type: string param:a type: null (or whitespace) param:b type: null (or whitespace) param:c So I came up with this regex which is doing the common mistake of repeating the

Regex - Capturing a Repeated Group

ⅰ亾dé卋堺 提交于 2020-01-21 10:10:10
问题 Alright, I've read the tutorials and scrambled my head too much to be able to see clearly now. I'm trying to capture parameters and their type info from a function signature. So given a signature like this: function(/*string*/a,b,c) I want to get the parts like this: type: string param:a param:b param:c This is Ok too: type: string param:a type: null (or whitespace) param:b type: null (or whitespace) param:c So I came up with this regex which is doing the common mistake of repeating the

NLog - Run-Time Parameters for Database Target

筅森魡賤 提交于 2020-01-21 08:22:06
问题 I am attempting to add some customization to my database log target. In my NLog.config I have this: <target name="DatabaseExample1" xsi:type="Database" dbProvider="System.Data.SqlClient" dbDatabase="${event-context:item=dbDatabase}" dbUserName="${event-context:item=dbUserName}" dbPassword="${event-context:item=dbPassword}" dbHost="${event-context:item=dbHost}" commandText="${event-context:item=commandText}"> </target> And in my C# code I have this: protected override void updateBeforeLog

Converting Lookup<TKey, TElement> into other data structures c#

强颜欢笑 提交于 2020-01-21 04:21:04
问题 I have a Lookup<TKey, TElement> where the TElement refers to a string of words. I want to convert Lookup into: Dictionary<int ,string []> or List<List<string>> ? I have read some articles about using the Lookup<TKey, TElement> but it wasn't enough for me to understand. Thanks in advance. 回答1: You can do that using these methods: Enumerable.ToDictionary<TSource, TKey> Enumerable.ToList<TSource> Lets say you have a Lookup<int, string> called mylookup with the strings containing several words,

Sample for Multi-process C# app like Google Chrome

筅森魡賤 提交于 2020-01-21 00:03:39
问题 Is Any body knows good sample for Multi-process C# app like Google Chrome. Thanks for help. 回答1: Useful blog post (with actual C# source code): http://wyday.com/blog/2010/multi-process-c-sharp-application-like-google-chrome-using-named-pipes/ Other related SO posts: Chrome / IE8 multi-process design, is it possible in .NET? Windows Forms application like Google Chrome with multiple processes 回答2: Took me sooo long to get all the pieces put together, but here it is: The XAML: <Window x:Class=

How does one correctly implement a MediaTypeFormatter to handle requests of type 'multipart/mixed'?

╄→尐↘猪︶ㄣ 提交于 2020-01-20 14:25:06
问题 Consider a web service written in ASP.NET Web API to accept any number files as a 'multipart/mixed' request. The helper method mat look as follows (assuming _client is an instance of System.Net.Http.HttpClient ): public T Post<T>(string requestUri, T value, params Stream[] streams) { var requestMessage = new HttpRequestMessage(); var objectContent = requestMessage.CreateContent( value, MediaTypeHeaderValue.Parse("application/json"), new MediaTypeFormatter[] {new JsonMediaTypeFormatter()}, new

How does one correctly implement a MediaTypeFormatter to handle requests of type 'multipart/mixed'?

折月煮酒 提交于 2020-01-20 14:22:51
问题 Consider a web service written in ASP.NET Web API to accept any number files as a 'multipart/mixed' request. The helper method mat look as follows (assuming _client is an instance of System.Net.Http.HttpClient ): public T Post<T>(string requestUri, T value, params Stream[] streams) { var requestMessage = new HttpRequestMessage(); var objectContent = requestMessage.CreateContent( value, MediaTypeHeaderValue.Parse("application/json"), new MediaTypeFormatter[] {new JsonMediaTypeFormatter()}, new