Questions tagged as 'c#'

1
answer

Save and update entities

public void InsertOrUpdate(T entity) { if (entity.Id == 0) { context.Set<T>().Add(entity); } else { var query = context.Set<T>().Find(entity.Id); context.Entry(query).Cur...
asked by 01.02.2017 / 15:57
1
answer

How to sort a List of Strings?

I have List<List<string>> and need to sort the main list according to some elements of the secondary see the illustration below. Ineedthefirstleveltobeinalphabeticalorder,andthesecondlevelisinascendingorderbutaccordingtoth...
asked by 30.01.2017 / 23:57
2
answers

How can I detect if the value of a textbox has letters?

How can you validate in TextBox when the user types letters instead of numbers a warning appears:    Only typing numbers in this field is allowed With which function can I check?     
asked by 18.04.2017 / 02:47
1
answer

TempData loses property when using Response.Redirect?

I have the following code in the pages that, to be accessed, you need to login: if (Session["Login"] == null) { TempData["msg"] = "É necessário realizar o login para acessar esta página!"; Response.Redirect("/Login/Index"); } This...
asked by 11.04.2017 / 13:05
1
answer

Correct way to update a Model from a ViewModel

I have the following question: Do I get a ViewModel in the Controller of ASP.NET. In the upgrade method I have two options: 1st option: transfer the ViewModel to the respective bank entity directly and update. 2nd option: Search firs...
asked by 17.06.2016 / 19:53
1
answer

Convert MER (Relationship Entity Model) diagram to VB.NET or C # classes [closed]

I developed the diagram of NFe XML layout tables, there are 58 tables with their relationships. I would like to generate the classes automatically from the diagram or can be through the database as well. Is there any tool for this?     
asked by 10.06.2016 / 14:23
1
answer

Library that matches the interpolation string of C # 6.0 at runtime

Does anyone know of any library that does run-time interpolation in strings? I know it would be possible to do using Replace() , but I do not want to go through the list with all the variables. For example: Programa de classe {...
asked by 22.06.2016 / 15:25
2
answers

Exception with timestamp in the database

I want to separately insert the time and date into the database, which have the timestamp and data fields, respectively. And I have the following code to add the fields: sqlInsertCabecalho.Parameters.AddWithValue("@colaborador",...
asked by 22.04.2016 / 16:19
1
answer

Show message if a certain word is entered

How do I get someone to write to cmd : > tree Display a message using the following command: Console.Write("");     
asked by 26.07.2016 / 23:18
3
answers

Adding zeros to the right TextBox C #

I have TextBox that only accepts decimal numbers. Butsometimestheuserdoesthefollowing: HowtomakeintheeventLeaveofTextBoxitaddthetwozerostotheright,inthecaseoftheimageabove,sothatthenumberisthus15,00?>Ihavetriedseveralwayswiththefollow...
asked by 02.08.2016 / 23:29