Questions tagged as 'entity-framework'

3
answers

Competition control in database insertion

I have a concurrency control problem when inserting data from a table. The scenario is as follows: There is a table that records daily data according to the user request, and this data can not be duplicated. The current concurrency control ch...
asked by 12.09.2014 / 15:39
1
answer

Code First versus Database First?

I'm used to creating projects in ASP.NET MVC with Entity Framework Database First. From a modeling, the database and the system are created. However, I see a lot of programmers prefer Code First, where the database depends on the system. W...
asked by 10.11.2014 / 21:51
2
answers

Relationship N for N and One for N with CodeFirst Data Annotations

How can I make the N to N and N to N relationships using Data Annotations? For example: A sales move has a user, and a user can have multiple moves. This same sales movement has several products, and each product can be in several movem...
asked by 21.06.2014 / 03:35
2
answers

Foreach C # vs ForEach () EF6

Follow the code below: % of EF6%: var result = ctx.Table.Where(x => x.User == "João").ToList(); result.ForEach(x => x.Read = true); ctx.SaveChanges(); ForEach() of C #: var result = ctx.Table.Where(x => x.User == "João...
asked by 07.06.2017 / 20:45
1
answer

In the Entity Framework, do the SingleOrDefault () and FirstOrDefault () methods have different behaviors?

What are the differences between SingleOrDefault() and FirstOrDefault() , and when to use it?     
asked by 09.06.2014 / 00:18
1
answer

How to use IValidatableObject?

How do I use IValidatableObject to not validate a foreign key property during a registration? I want to validate only the foreign key in the edit.     
asked by 27.10.2015 / 02:11
4
answers

Entity Framework foreign key

My domain: public class SBE_ST_CorpoDocente { public int Id { get; set; } public string Nome { get; set; } public virtual ICollection<SBE_ST_Curso> Cursos { get; set; } } public class SBE_ST_Curso { public int Id { get;...
asked by 11.08.2014 / 20:00
3
answers

How to make a query through LINQ ignoring accents?

I would like to know if you can do a query with LINQ that compares two strings and ignores their accents. That's not my Collation in the database is set to AI and that I do not need to replace in the strings to exit by re...
asked by 12.05.2017 / 04:10
1
answer

How to handle duplicate key error?

How do I handle duplicate key errors? I need to display message to user that "Item is already registered" Something like this: try{ //tenta inserir no Banco de Dados context.Produto.Add(_produto); context.SaveChanges(); }catch(exceç...
asked by 02.10.2015 / 01:26
2
answers

Serialize object list for JSON: A circular reference was detected while serializing an object of type

I'm trying to Serialize a list of objects to Json and I have received the following error: An exception of type    'System.InvalidOperationException' occurred in   Microsoft.Web.Extensions.dll but was not handled in user code   Additio...
asked by 07.10.2014 / 15:36