作業単位とリポジトリ フレームワーク |公式URF、追跡可能なエンティティ、デザイン ファクトリー チーム
URF.Core は機能が完成し、URF.NET (レガシー .NET) と完全に同等になりました。 URF.Core は、アーキテクチャ、設計、実装に焦点を当てて完全に書き直され、vNext の最上位のリクエストを実装しました。ASP.NET Core Web API、OData、 Angular および Kendo UI を備えた完全な CRUD サンプルが含まれています。
バージョン 3.1.1 では、MongoDb の実装により NoSQL ドキュメント データベースのサポートが追加されました。
EF Core 3.x と MongoDb のサンプルが提供されています。
フットプリントが小さい (レガシー) URF.NET に忠実であり続けます。 URF.Core URF.Core (合計 7 クラス) と URF.NET (合計 12 クラス)。
すべての実装を仮想化したので、あらゆるチーム/プロジェクト/開発者のユースケースだけでなく、エッジケースでもオーバーライドできるようになりました。
いつものように、これはチームとコミュニティ内の宗教的な議論です。 (従来の) URF.NET と同様に、チームのアーキテクチャ、設計と実装、スタイルに応じて、IQueryable または IEnumerable、あるいは両方を選択するオプションをチームに提供しました。 URF.NET として、また、 IQueryable
漏れやすい抽象化として公開するリポジトリ パターンを感じているチームの場合は、単純に URF のIQuery
API を使用します。これにより、IQueryable のすべての Fluent 機能が提供されますが、純粋な Entity または IEnumerable が返されます。IQueryable を使用した場合と同様に、やはり URF です。 .Core と URF.NET は両方ともサポートされているため、チームは 3 つのパス/オプションのうち、自分のチーム/プロジェクトにとって最も適切なものを完全に自由に選択できます。
public class ProductsController : ODataController
{
private readonly IProductService _productService ;
private readonly IUnitOfWork _unitOfWork ;
public ProductsController (
IProductService productService ,
IUnitOfWork unitOfWork )
{
_productService = productService ;
_unitOfWork = unitOfWork ;
}
// e.g. GET odata/Products?$skip=2&$top=10
[ EnableQuery ]
public IQueryable < Products > Get ( ) => _productService . Queryable ( ) ;
// e.g. GET odata/Products(37)
public async Task < IActionResult > Get ( [ FromODataUri ] int key )
{
if ( ! ModelState . IsValid )
return BadRequest ( ModelState ) ;
var product = await _productService . FindAsync ( key ) ;
if ( product == null )
return NotFound ( ) ;
return Ok ( product ) ;
}
// e.g. PUT odata/Products(37)
public async Task < IActionResult > Put ( [ FromODataUri ] int key , [ FromBody ] Products products )
{
if ( ! ModelState . IsValid )
return BadRequest ( ModelState ) ;
if ( key != products . ProductId )
return BadRequest ( ) ;
_productService . Update ( products ) ;
try
{
await _unitOfWork . SaveChangesAsync ( ) ;
}
catch ( DbUpdateConcurrencyException )
{
if ( ! await _productService . ExistsAsync ( key ) )
return NotFound ( ) ;
throw ;
}
return NoContent ( ) ;
}
// e.g. PUT odata/Products
public async Task < IActionResult > Post ( [ FromBody ] Products products )
{
if ( ! ModelState . IsValid )
return BadRequest ( ModelState ) ;
_productService . Insert ( products ) ;
await _unitOfWork . SaveChangesAsync ( ) ;
return Created ( products ) ;
}
// e.g. PATCH, MERGE odata/Products(37)
[ AcceptVerbs ( " PATCH " , " MERGE " ) ]
public async Task < IActionResult > Patch ( [ FromODataUri ] int key , [ FromBody ] Delta < Products > product )
{
if ( ! ModelState . IsValid )
return BadRequest ( ModelState ) ;
var entity = await _productService . FindAsync ( key ) ;
if ( entity == null )
return NotFound ( ) ;
product . Patch ( entity ) ;
_productService . Update ( entity ) ;
try
{
await _unitOfWork . SaveChangesAsync ( ) ;
}
catch ( DbUpdateConcurrencyException )
{
if ( ! await _productService . ExistsAsync ( key ) )
return NotFound ( ) ;
throw ;
}
return Updated ( entity ) ;
}
// e.g. DELETE odata/Products(37)
public async Task < IActionResult > Delete ( [ FromODataUri ] int key )
{
if ( ! ModelState . IsValid )
return BadRequest ( ModelState ) ;
var result = await _productService . DeleteAsync ( key ) ;
if ( ! result )
return NotFound ( ) ;
await _unitOfWork . SaveChangesAsync ( ) ;
return StatusCode ( ( int ) HttpStatusCode . NoContent ) ;
}
}
URF.Core は完全に書き直され、すべてが箱から出してすぐに完全にtask
、 async
、 await
になりました。こうすることで、チームは自動的に非同期パフォーマンスの向上に最適なスレッド管理を実現できるようになります。
© 2017 URF.NET 無断複写・転載を禁じます。