コード例 #1
0
 /// <summary>
 /// Get repository type.
 /// </summary>
 /// <typeparam name="TEntityDTO">Entity</typeparam>
 /// <typeparam name="TEntity">Entity DTO</typeparam>
 /// <param name="_"></param>
 /// <returns>Type</returns>
 public static Type GetRepositoryType <TEntityDTO, TEntity>(this IGenericRepositoryDTO <TEntityDTO, TEntity> _)
     where TEntityDTO : class, IZDTOBase <TEntityDTO, TEntity>
     where TEntity : class, IZDataBase
 {
     return(typeof(TEntityDTO));
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: EasyLOB/EasyLOB-Chinook-1
        private static void ODataUnitOfWorkDemo()
        {
            Console.WriteLine("\nUnit of Work Demo\n");

            try
            {
                IUnitOfWorkDTO unitOfWork = new ChinookUnitOfWorkOData();
                IGenericRepositoryDTO <Chinook.Data.GenreDTO, Chinook.Data.Genre> repository = unitOfWork.GetRepository <Chinook.Data.GenreDTO, Chinook.Data.Genre>();
                ZOperationResult operationResult = new ZOperationResult();

                Chinook.Data.GenreDTO genre = new Chinook.Data.GenreDTO();

                // Count

                Console.WriteLine("COUNT: " + repository.CountAll().ToString() + " Genre(s)");

                // Create

                if (operationResult.Ok)
                {
                    genre.Name = "A Genre";
                    if (repository.Create(operationResult, genre))
                    {
                        if (unitOfWork.Save(operationResult))
                        {
                            Console.WriteLine("CREATE: {0} {1}", genre.GenreId, genre.Name);
                        }
                    }
                }

                // Update

                if (operationResult.Ok)
                {
                    genre.Name = "A Genre Updated";
                    if (repository.Update(operationResult, genre))
                    {
                        if (unitOfWork.Save(operationResult))
                        {
                            Console.WriteLine("UPDATE: {0} {1}", genre.GenreId, genre.Name);
                        }
                    }
                }

                // Delete

                if (operationResult.Ok)
                {
                    if (repository.Delete(operationResult, genre))
                    {
                        if (unitOfWork.Save(operationResult))
                        {
                            Console.WriteLine("DELETE");
                        }
                    }
                }

                if (!operationResult.Ok)
                {
                    Console.WriteLine(operationResult.Text);
                }
            }
            catch (Exception exception)
            {
                WriteException(exception);
            }
        }