.net-4.5

Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type

自作多情 提交于 2019-12-28 04:05:07
问题 I am working with .NET4.5 and VS2013, I have this query that gets dynamic result from db. dynamic topAgents = this._dataContext.Sql( "select t.create_user_id as \"User\", sum(t.netamount) as \"Amount\" from transactiondetail t where t.update_date > sysdate -7 group by t.create_user_id") .QueryMany<dynamic>(); Following statement fails with compilation error Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression

Does .Net 4.5 support XML 1.1 yet (for characters invalid in XML 1.0)?

廉价感情. 提交于 2019-12-28 02:51:28
问题 This is in the context of Web Services (client end). I need to interface with a back-end system (Java) and it is a requirement to transmit some control characters in the &#14; and &#31; range. I'm well aware that XML 1.0 doesn't support this, but am interested to know if the .NET 4 platform or .NET 4.5 web services framework support conversations in XML 1.1. 回答1: No, it doesn't look like XmlReader (the core of much of the XML support in .NET) supports 1.1: using System; using System.IO; using

Infinite IObservable from Task function and toggle observable with parameters

人走茶凉 提交于 2019-12-25 09:34:43
问题 This is follow up question to : Infinite IObservable from Task function and toggle observable Above question asks if it is possible to create a repeating IObservable<TResult> from IObservable<bool> toggle and Task<TResult> query , so that query is called repeatedly if last toggle was true and not called at all if last toggle is false . That seems to be pretty easily achieved using Defer and Switch methods. But that has problem, because the query is not parametrized. Concretely, there are two

Task based processing with a limit for concurrent task number with .NET 4.5 and c#

不羁的心 提交于 2019-12-25 06:59:32
问题 Following this, could anyone post a barebone solution for the following task, targeting .NET 4.5 (and WPF UI on a bigger scale)? Basically I'm looking for a functional analog of any torrent application implemented on .NET 4.5 and c#. The task: I have IEnumerable<IProcessable> , containing 1000 instances of IProcessable , IProcessable has Process(int argument) method, taking from 1 to 10 seconds to execute. I want to loop through the collection and process each instance of IProcessable ,

C# ?? operator with DBNull (Coalesce-like result) [duplicate]

不想你离开。 提交于 2019-12-25 04:19:42
问题 This question already has answers here : Possible to use ?? (the coalesce operator) with DBNull? (6 answers) Closed 5 years ago . I'm getting DBNull results from DB. Trying to apply ?? operator to it like result["field1"] ?? result["field2"] field1 = DBNull field2 = 4 but it doesn't work, returns {} because result["field1"] is not null (it's DBNull). I expect to get that 4 from it. Tried to do result["field1"] = null first, but it doesn't work, it's still DBNull type. The question is how to

ComboBox data filtering in xaml

一世执手 提交于 2019-12-25 04:15:17
问题 I am using a Telerik combobox but I think the question is relevant to the standard wpf combobox. The control is bound to an observable collection of “TableRecord” where this object looks like this: public enum RecordState { Orginal, Added, Modified, Deleted } public class TableRecord<T> { public Guid Id { get; set; } public string DisplayName { get; set; } public T Record { get; set; } public RecordState State { get; set; } public TableRecord(Guid id, string displayName, T record, RecordState

Is List<Object> a good replacement for ArrayList?

筅森魡賤 提交于 2019-12-25 02:22:15
问题 ArrayList , which I use in legacy Compact Framework code, does not seem to be available in newfangled (.NET 4.5.1) code. I am storing instances of custom classes in it. What is a good replacement for it - List<Object> , or is there something more suitable? 回答1: As @HighCore mentioned in his comment, you should use the generic form of List, List<T> . If you have several classes defined that you need to include in that List, they probably have common properties, methods. In that case, you can

Facade a class without writing lots of boilerplate code?

跟風遠走 提交于 2019-12-25 01:45:14
问题 Let's say I have a class from a 3rd-party, which is a data-model. It has perhaps 100 properties (some with public setters and getters, others with public getters but private setters). Let's call this class ContosoEmployeeModel I want to facade this class with an interface (INavigationItem, which has Name and DBID properties) to allow it to be used in my application (it's a PowerShell provider, but that's not important right now). However, it also needs to be usable as a ContosoEmployeeModel.

Calling .asmx webservice from jQuery: GET is not allowed?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 18:09:59
问题 I have a simple page. On load, it calls a web service, and then I get the following error: an attempt was made to call the method using a GET request, which is not allowed My JS-code: function getTutors() { var url = '<%= ResolveUrl("~/services/tutorservice.asmx/gettutors") %>'; $.ajax({ type: "GET", data: "{'data':'" + 'test-data' + "'}", url: url, contentType: "application/json; charset=utf-8", dataType: "json", success: function (d) { alert('succes'); return d; }, error: function () {

How to use StreamWriter.WriteAsync and catch exceptions?

六月ゝ 毕业季﹏ 提交于 2019-12-24 15:17:40
问题 I have simple function to write files. public static void WriteFile(string filename, string text) { StreamWriter file = new StreamWriter(filename); try { file.Write(text); } catch (System.UnauthorizedAccessException) { MessageBox.Show("You have no write permission in that folder."); } catch (System.Exception e) { MessageBox.Show(e.Message); } file.Close(); } How can I convert my code to use StreamWriter.WriteAsync with try-catch? 回答1: async public static void WriteFile(string filename, string