예제 #1
0
        /// <summary>
        /// Создать объект, где хранятся данные сущности "DummyOneToMany".
        /// </summary>
        /// <returns>Объект, где хранятся данные сущности "DummyOneToMany".</returns>
        public DataBaseObjectDummyOneToMany CreateObjectDummyOneToMany()
        {
            var loader = new DataBaseLoaderDummyOneToMany();

            loader.LoadDataFrom(this);
            return(loader.Data);
        }
예제 #2
0
        private async Task <DataBaseObjectDummyOneToMany> SaveObjectDummyOneToMany(
            DataBaseObjectDummyOneToMany obj
            )
        {
            DataBaseObjectDummyOneToMany result = null;

            using (var source = CreateDbContext())
            {
                if (obj.Id > 0)
                {
                    result = await source.DummyOneToMany
                             .FirstAsync(x => x.Id == obj.Id)
                             .CoreBaseExtTaskWithCurrentCulture(false);

                    var loader = new DataBaseLoaderDummyOneToMany(result);

                    loader.LoadDataFrom(obj);
                }
                else
                {
                    var entity = DataEntityObjectDummyOneToMany.Create(obj);

                    var entry = source.DummyOneToMany.Add(entity);

                    result = entry.Entity;
                }

                await source.SaveChangesAsync().CoreBaseExtTaskWithCurrentCulture(false);
            }

            return(result);
        }