Posts by Miguel Angelo • 28,526 points
429 posts
-
12
votes6
answers7191
viewsA: How to put default (default) arguments in a Javascript function?
There is no way to do this in a practical way. However, this answer does not please me, and knowing that javascript is such a dynamic language, I decided to use a little time to reflect, search and…
-
4
votes1
answer122
viewsA: Is there any advantage in avoiding type specification redundancy?
In the cases presented, as the value being passed is a literal, it is very easy to see which type will be inferred by C#... so in this case, I would certainly remove the specification of the type of…
c#answered Miguel Angelo 28,526 -
3
votes1
answer460
viewsA: Receiving several Textbox values
If the student list is in the template you pass to the view you can use a EditorFor... I don’t know what your model looks like, so I’m going to assume a structure like below: @for (var i = 0; i <…
-
5
votes2
answers129
viewsA: Get user-created methods
You can check which type is the method declaration using the property DeclaringType of MethodInfo, so you can filter the way you want: public string[] ListarMetodos() { var t = Objeto.GetType();…
-
8
votes1
answer5290
viewsA: Method that returns a class
If the type is in the same Assembly that is running, you can do so: var t = Assembly.GetExecutingAssembly().GetTypes().First(x => x.Name == "Calculadora"); And then use the type to create a new…
-
0
votes4
answers2258
viewsA: Conditional Data Annotation MVC4
You can implement an attribute that performs a custom validation in the same way as the Required, but only when the condition is satisfied, and use this attribute instead of the Required. In this…
-
27
votes4
answers9073
viewsA: What is the difference between using . js and .min.js files?
It was taken as convention, to name minified javascript files, with the termination .min.js. Differences The difference between the minified and non-minified file is the file size... a functionality…
-
3
votes1
answer1034
viewsA: Update edmx from the bank
You have to generate the entities again... try to right click on the EDMX, there must be a menu called Run Custom Tool. This menu item serves to run the tool to generate the entities, which in this…
-
11
votes1
answer1494
viewsA: Javascript ternary condition with only one value
This is possible with the operator && as follows: (test) && test1(); In that other answer, What is the && in between strings operator?, I show how exactly the operator works…
-
2
votes2
answers954
viewsA: Filter on Where the longest date with LINQ
You can sort the query so that the object with the highest date appears in front, and then take the first record: var resultado = (from ci in webDB.T_Controle_Importacao .OrderByDescending(ci =>…
-
3
votes2
answers771
viewsA: Bring three possible results with Lambda
You can use LINQ syntax to make it easy to create a value that contains the difference, using let, and then use this calculated value in select to return the values you want, using the ternary…
-
11
votes3
answers11852
viewsA: How to separate a String according to a separator in C#?
You can use the method string.Split: var array = valores.Split('#'); If you want to pass options, you have to do so: var array = valores.Split(new char[] { '#' },…
-
5
votes1
answer543
viewsA: When a DLL goes up in the "bin" folder all users lose session
To use the external session server (out-of-process), you have to: ensure that the session server is active The ASP.NET session server is installed as a Windows service In the Windows Applications…
-
3
votes2
answers351
viewsA: Jquery . click or Function
Advantage in putting direct code in the element One of the difficulties I have with jQuery is in maintaining code that I didn’t make. The problem is in identifying where are in javascript, the code…
-
6
votes2
answers1076
viewsA: How to put a @ inside {} in MVC
Alternative 1 Just type in the duplicate symbol: @@. This will be turning into just one @ in output. In short, correlating with your question, to write "@RenderBody()" in the output of an Razor…
-
4
votes2
answers2320
viewsA: Two buttons to perform the same function?
You are trying to use the ID as a class, to select multiple elements. When jQuery finds the ID selector (i.e. #id), it uses a specialized browser method (getElementById), which returns only the…
javascriptanswered Miguel Angelo 28,526 -
3
votes3
answers285
viewsA: "Gambiarra" in C# with XML, I would like suggestions for improvement
Since the return unit are consulates, it is simpler if we start the direct selection with the consulates, and obtain the other information, in the sense of the ancestral or descending elements,…
-
9
votes3
answers1436
viewsA: How does method management work in C#memory?
Some conceptions you formulated are wrong. Structs do not necessarily exist in the stack. A struct is a set of data that is stored in the form of a value, rather than a reference that points…
-
1
votes1
answer90
viewsA: XML duplicating the reading of the results
The problem is in the assignment telefone = f.Element("telefone").Value, for the method Element returns only one element, in which case it will be the first one found. Instead, use the method…
-
2
votes3
answers2867
viewsA: Capitalizing on C#names
A very simple way to do this is by using Regex.Replace and replace all words with their title-case versions, except in some special cases, which will be placed in a normalization dictionary: static…
-
3
votes1
answer270
viewsA: Motivation for OWIN
This technology allows, for example, replacing the need for IIS to serve websites or webservices. The motivation is flexibility, which in the case of replacing the OSI can mean more performance.…
-
37
votes4
answers4635
viewsA: To what extent is it not advisable to use an ORM?
I am in favour of a mixed approach Use the ORM as much as possible to improve readability and productivity. In C# or VB.Net it is possible to use LINQ, which is an extraordinary tool in terms of…
-
9
votes2
answers390
viewsA: How to implement A/B testing?
How A/B testing works: A/B testing requires a mass of data already collected to draw conclusions. Therefore, for a new system it is not possible to complete anything immediately. The process…
testinganswered Miguel Angelo 28,526 -
9
votes1
answer100
viewsA: How to define Titlecase using regex in Javascript?
Just replace g2.toLowerCase() by just g2, so that there is no passage into the lower case characters of those in the middle of the word: var titleCase = function(s) { return s.replace(/(\w)(\w*)/g,…
-
2
votes3
answers553
viewsA: What is the difference between a web service in the same project and a different project in the same project?
If you are creating REST services, I strongly recommend using Webapi. The concepts are similar to those of ASP.NET MVC, having controllers and actions... and therefore it is easier to reuse your…
-
27
votes8
answers49747
viewsA: How do I remove accents in a string?
Using LINQ is very practical: public static string RemoverAcentuacao(this string text) { return new string(text .Normalize(NormalizationForm.FormD) .Where(ch => char.GetUnicodeCategory(ch) !=…
-
1
votes1
answer79
viewsA: Controllers should have a single responsibility?
I see no problem in doing this, as long as the referred contacts have some relationship with the client, making explicit that they are a client’s contacts. If there are other ways, other than…
asp.net-mvcanswered Miguel Angelo 28,526 -
2
votes2
answers1311
viewsA: How to get position of a sub-list within another list?
You can nest two loops to do this: for each valid position of the main list, check whether each item of the list being searched beats. If you reach the end without finding, then returns a negative…
-
6
votes5
answers573
viewsA: Why are you wearing shorts?
Not that it gets slower, because the CPU even being 64 bits, still has instructions to deal with numerical types smaller than the native. The char of . Net for example, has 16 bits, which is…
-
3
votes4
answers6284
viewsA: How does an empty constructor work?
When no constructor is specified in a class, C# will automatically compile a constructor with no public parameters, which will leave all fields with the default values of each type. The default…
-
5
votes1
answer672
viewsA: How to understand and start a Rest or Soap service
A REST webservice is lighter than SOAP because the data traffic structure is generally smaller. This happens because when using SOAP the data transfer is done with XML, while a REST service usually…
web-serviceanswered Miguel Angelo 28,526 -
12
votes2
answers14336
viewsA: Some way to style "parent" element with CSS
That’s what they call selector, whereas cannot do this using CSS3. This has already been proposed, and something similar is to be implemented by CSS4* level 4 selectors, using the marking $ before…
-
5
votes3
answers5013
viewsA: Subtraction of multiple selects
In this case it would be possible to transform all these queries into Queries, within a SELECT, each as a column, and then transform everything, again into a subquery in the FROM clause, and use the…
sqlanswered Miguel Angelo 28,526 -
9
votes2
answers9163
viewsA: How to force files of type . txt to be downloaded
According to this post , you can do this by changing the file .htaccess with the following: <FilesMatch "\.(?i:txt)$"> ForceType application/octet-stream Header set Content-Disposition…
-
4
votes1
answer2186
viewsA: How to use generic types with type parameters?
It is possible to do this through reflection. To call the method using reflection, given a type t obtained from the dictionary: public virtual T Get<T>(int id) where T : CD.IDomainModel {…
-
19
votes2
answers6538
viewsA: Meaning of ?: ?= ?! ? <= ? <! in a regex
If you are referring to . Net regexes, using the class Regex, these symbols can be used when starting a group with parentheses: ( + symbols + ... + ) What do they mean: ?: Undetected group:…
regexanswered Miguel Angelo 28,526 -
25
votes8
answers2113
viewsA: Is using customer validation enough?
Validating data being sent by the user only in javascript is not enough because of: If the user disables javascript, you may end up with invalid data on the server if the user is malicious, it can…
-
70
votes2
answers11641
viewsA: What is Reflection. Why is it useful?
Reflection is a term used to indicate the ability to obtain metadata on the compiled program itself, in Portuguese it can be referred to as reflection even. As well as metadata? Getting information…
-
14
votes2
answers9155
viewsA: What is serialization? When to use? How to implement in C#?
Only complementing the answer already given by @Ciganomorrisonmendez. Sometimes it is simply not possible to avoid serialization: transmit an object over the network transmit an object between…
-
2
votes2
answers1016
viewsA: Regex | Take group split
Do you want to redeem only the right values? In this case, you should create a group only at the value: <[^>]+>Alíquota<[^>]+><[^>]+>(\d+\,\d+)<[^>]+> Note that…
-
2
votes2
answers126
viewsA: Create Jquery plugin
In its previous code there was this error, in addition to the wrong use of this within the closure, as indicated in EDIT below. Using this within the plugin method In this case, the this is already…
jqueryanswered Miguel Angelo 28,526 -
2
votes3
answers240
viewsA: How to display "from" inside the Datetimepicker
Use simple quotes inside the string, as if they were substrings: dtApartir.CustomFormat = "d' de 'MMMM' de 'yyyy";
-
4
votes1
answer244
viewsA: How to support user-added columns without updating the EF model?
I don’t think Entity Framework will care about the additional columns as long as they don’t hinder the rescue of entities without additional values. Adding columns without disturbing the Entity To…
-
12
votes1
answer132
viewsA: Why do CDN web addresses not specify protocol?
This indicates the browser to use the same protocol in the address bar of the page making the request. Does that mean that: if you are on a page served via HTTP, the request will be made to HTTP CDN…
-
1
votes4
answers6797
viewsA: Creating a JS bot
You can use the Phantomjs to simulate the browser, using scripts made using javascript. What you can do with Phantomjs: navigation automation (probably that’s what you want) website testing take…
javascriptanswered Miguel Angelo 28,526 -
5
votes2
answers692
viewsA: jQuery - Switching background-image of an element
One problem is that you are setting several setInterval, one for each image, which causes there to be a lot of competing timers to make changing the image being displayed. You don’t need one for,…
-
4
votes1
answer70
viewsA: Doubt of licking on a guy
It should be something like: var traslado = ((OfferV2[])SessaoUtil.Recuperar("MontaTraslado")) .Where(x => x.ProductName.Contains("Traslado")) .ToArray();
-
4
votes4
answers4168
viewsA: Convert string to Time
I would turn the string to TimeSpan and then add to DateTime that already exists: var dateTime = new DateTime(2014, 04, 14); var finalDateTime = dateTime + TimeSpan.Parse("12:10"); If you are using…
-
8
votes2
answers330
viewsA: Implement composite key C#
I don’t think that’s the ideal way. The . Net offers the following ways to compare the equality between two objects: the virtual method Equals which can be implemented in order to compare objects to…
c#answered Miguel Angelo 28,526 -
3
votes1
answer125
viewsA: How to show correct name on an Enum bitwise?
Remove the attribute Flags... because that’s exactly what the Flags attribute is for, to indicate that there is a combination of values... if you want to show a value without considering it as a…