Exemplo n.º 1
0
        public void InsertOrUpdate(Group group)
        {
            if (group.Id == default(int))
            {
                // New entity
                context.Groups.Add(group);
            }
            else
            {
                // Existing entity
                if (context.Entry(group).State == EntityState.Detached)
                {
                    var entityKey = context.Groups.Create().GetType().GetProperty("Id").GetValue(group);

                    context.Entry(context.Set <Group>().Find(entityKey)).CurrentValues.SetValues(group);
                }
                //context.Entry(group).State = EntityState.Modified;
            }
        }