.net

LINQ performance - deferred v/s immediate execution

只谈情不闲聊 提交于 2021-02-07 08:55:42
问题 I have seen that sometimes the performance of LINQ to Objects queries can be improved significantly if they forced to execute immediately by using .ToArray() , but can't quite understand why. For example, in the sample below, the execution of the function Deferred() is much slower than the function Immediate() , and grows exponentially with the value of limit (perhaps it was exponential in both functions, but execution time with Immediate() was too little for me to say definitively). public

LINQ performance - deferred v/s immediate execution

谁说我不能喝 提交于 2021-02-07 08:53:55
问题 I have seen that sometimes the performance of LINQ to Objects queries can be improved significantly if they forced to execute immediately by using .ToArray() , but can't quite understand why. For example, in the sample below, the execution of the function Deferred() is much slower than the function Immediate() , and grows exponentially with the value of limit (perhaps it was exponential in both functions, but execution time with Immediate() was too little for me to say definitively). public

Subtype fieldnumber order dependent in protobuf-net

岁酱吖の 提交于 2021-02-07 08:53:39
问题 I can see that protobuf-net seems to need to have deterministic ordering on the run type model. What's a good strategy to use without the need of having attributes on each class for the ordering. How does protobuf it self do if it were that you were implementing by attributes instead ? model.Add(typeof(IMessage), false).AddSubType(8500, typeof(DogBarkedEvent)); model.Add(typeof(IMessage), false).AddSubType(8501, typeof(DogBarkedEvent2)); if I create a new model and try to deserialize with

Subtype fieldnumber order dependent in protobuf-net

强颜欢笑 提交于 2021-02-07 08:52:36
问题 I can see that protobuf-net seems to need to have deterministic ordering on the run type model. What's a good strategy to use without the need of having attributes on each class for the ordering. How does protobuf it self do if it were that you were implementing by attributes instead ? model.Add(typeof(IMessage), false).AddSubType(8500, typeof(DogBarkedEvent)); model.Add(typeof(IMessage), false).AddSubType(8501, typeof(DogBarkedEvent2)); if I create a new model and try to deserialize with

Subtype fieldnumber order dependent in protobuf-net

北城以北 提交于 2021-02-07 08:52:00
问题 I can see that protobuf-net seems to need to have deterministic ordering on the run type model. What's a good strategy to use without the need of having attributes on each class for the ordering. How does protobuf it self do if it were that you were implementing by attributes instead ? model.Add(typeof(IMessage), false).AddSubType(8500, typeof(DogBarkedEvent)); model.Add(typeof(IMessage), false).AddSubType(8501, typeof(DogBarkedEvent2)); if I create a new model and try to deserialize with

How to get Class Metadata into JSON string

妖精的绣舞 提交于 2021-02-07 08:39:56
问题 How to generate JSON of Class meta data. for eg. C# Classes public class Product { public int Id { get; set; } public string Name { get; set; } public bool IsActive { get; set; } public Description Description { get; set; } } public class Description { public string Content { get; set; } public string ShortContent { get; set; } } JSON [ { "PropertyName" : "Id", "Type" : "Int", "IsPrimitive" : true }, { "PropertyName" : "Name", "Type" : "string", "IsPrimitive" : true }, { "PropertyName" :

How to get Class Metadata into JSON string

眉间皱痕 提交于 2021-02-07 08:39:46
问题 How to generate JSON of Class meta data. for eg. C# Classes public class Product { public int Id { get; set; } public string Name { get; set; } public bool IsActive { get; set; } public Description Description { get; set; } } public class Description { public string Content { get; set; } public string ShortContent { get; set; } } JSON [ { "PropertyName" : "Id", "Type" : "Int", "IsPrimitive" : true }, { "PropertyName" : "Name", "Type" : "string", "IsPrimitive" : true }, { "PropertyName" :

how to enable backspace,delete into maskededitextender date field

北城余情 提交于 2021-02-07 08:37:52
问题 I have a textbox as a date field . but due masked editor extender I can't edit dates in chrome or firefox backspace and delete is not working in chrome or firefox . codes are below <asp:TextBox ID="txtStartDate" CssClass="txtStartDate" runat="server" MaxLength="10" onkeydown="return allowBackSpace(event);" />  <asp:RequiredFieldValidator ID="startDateRequiredFieldValidator" runat="server" ValidationGroup="Dates" ControlToValidate="txtStartDate" EnableClientScript="True" Display="None" Text="*

Unable to cast object of type 'System.Data.DataRowView' to type 'System.IConvertible'

不打扰是莪最后的温柔 提交于 2021-02-07 08:35:31
问题 I m using in C# Code int i = Convert.ToInt32(ddlDivisionId.SelectedValue); at that time this type of error accrued.. Unable to cast object of type 'System.Data.DataRowView' to type 'System.IConvertible' how can i solve it ? Please help 回答1: It looks like your ddlDivisionId.SelectedValue is returning a DataRowView . I assume you bound a DataTable or similar to your dropdown list (assuming that is what we are looking at). In this case you will need to treat the ddlDivisionId.SelectedValue as a

C# Compiled lambda expressions instance creation and/or garbage collection?

我只是一个虾纸丫 提交于 2021-02-07 08:32:26
问题 Consider the following code sample: using System; using System.Linq.Expressions; public class Class1<T, Y> { public Class1(Expression<Func<T, Y>> mapExpression) { GetValue = mapExpression.Compile(); } public Func<T, Y> GetValue { get; protected set; } } public class DataClass { public long Data { get; set; } } Now suppose that I make in different places new instances of Class1, e.g. var instance1 = new Class1<DataClass, long>(x => x.Data); var instance2 = new Class1<DataClass, long>(x => x