Questions tagged as 'c#'

2
answers

Call a method equivalent to a string

Consider the following class: public class AnimationManager : MonoBehaviour { public GameObject[] Enemies; void OnTriggerEnter2D (Collider2D o) { if (o.tag == "Player") foreach(GameObject Enemy in Enemies)...
asked by 31.08.2015 / 21:30
1
answer

What is the "class" constraint in a generic type?

In the line below: public class Tree<TItem> where TItem : IComparable<TItem> This line I'm creating the definition of type TItem where TItem implements the IComparable interface, ie I'm creating a generic ty...
asked by 15.09.2015 / 17:00
1
answer

Random order with Entity Framework

I would like to translate the following SQL statement to a lambda expression: SELECT TOP 1 * FROM tbPessoa order by NEWID() What do I put in the OrderBy that will be accepted? var pessoa = contexto.tbPessoa.OrderBy(???).FirstOrDe...
asked by 04.01.2017 / 14:34
1
answer

Modeling with Code First so you can change databases

If I generate my database for MySQL using the concept of Code First can I change it to SQL Server in the future? Do you need to change the classes or just the config and provider ?     
asked by 17.04.2017 / 15:27
1
answer

Customize message by time

I wanted to customize the greeting message depending on the time. Ex: Hora menor que 12h. "Bom dia" Hora menor que 18h. "Boa tarde" I made with if and else but wanted a better method. //Pegando a hora int hora = DateTime...
asked by 28.03.2017 / 15:19
2
answers

Receive int nullable in Razor (@ Html.TextboxFor)

I have a Carro object and I have an integer and nullable property called AnoInspecao . When creating, I can create a car object with the null inspection year (without typing anything) and persist in the database normally. var carro = ne...
asked by 03.12.2015 / 18:44
1
answer

Simple National Consultation (by CNPJ) - C #

I am implementing in C # an Enterprise Query Opting for the Simple National Tax Regime through this link link I have already implemented another similar query (search the cadastral data of the CNPJ informed) and tried to base it on the same...
asked by 29.01.2016 / 20:17
1
answer

Visual Studio or Eclipse code review rule

I would like to know if there is an add-in for visual studio that guarantees that while I am in the development environment make some changes but when I generate the project build, this commented part is reviewed warning me that in production wi...
asked by 03.02.2016 / 20:00
1
answer

Rounding Up - C #

I use a program to correct my inventory of the sped tax file that I submit for revenue. But I'm in trouble because unitary products are coming out with broken value. Example below, the product had (50) units after I step the program it gets b...
asked by 18.12.2015 / 19:24
2
answers

Fluent API relationship questions for EF 5

I have two classes: User > Contains your PK (ID). UsuarioP > Contains user ID (FK). Class User.cs public Usuario() { this.UsuariosP = new List<UsuarioP>(); } public int Id { get; set; } (...) public virtual ICo...
asked by 28.09.2015 / 15:21