< BACK TO BLOG

kr.bbon.EntityFrameworkCore.Extensions Package

πŸ—“οΈ2021-01-03

Nuget: kr.bbon.EntityFrameworkCore.Extensions νŽ˜μ΄μ§€μ—μ„œ νŒ¨ν‚€μ§€λ₯Ό 찾을 수 μžˆμŠ΅λ‹ˆλ‹€.

κ°œμš”

Microsoft.EntityFrameworkCore νŒ¨ν‚€μ§€λ₯Ό μ‚¬μš©ν•˜λ©΄μ„œ, 데이터λ₯Ό μ •λ ¬λ₯Ό 자주 μ‚¬μš©ν•©λ‹ˆλ‹€.

이 λ•Œ, λ¬Έμžμ—΄ ν˜•μ‹μœΌλ‘œ ν•„λ“œ μ΄λ¦„μœΌλ‘œ μ •λ ¬ν•  수 있으면 νŽΈλ¦¬ν•  것 κ°™μ•„μ„œ ν™•μž₯을 μž‘μ„±ν–ˆμŠ΅λ‹ˆλ‹€.

κΈ°λŠ₯

Sort ν™•μž₯ λ©”μ„œλ“œ

IQueryable μΈν„°νŽ˜μ΄μŠ€μ— Sort ν™•μž₯ λ©”μ„œλ“œλ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€.

Sort ν™•μž₯λ©”μ„œλ“œλŠ” λ‚΄λΆ€μ μœΌλ‘œ OderBy, OrderByDescending, ThenBy, ThenByDescending ν™•μž₯ λ©”μ„œλ“œλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

Sort(string fieldName, [bool isAscending = true])

fieldName 은 λŒ€μ†Œλ¬Έμžλ₯Ό κ΅¬λΆ„ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. fieldName 에 ν•΄λ‹Ήν•˜λŠ” ν•„λ“œλ₯Ό 찾을 수 μ—†μœΌλ©΄ μ˜ˆμ™Έκ°€ λ°œμƒν•©λ‹ˆλ‹€.

μ‚¬μš©λ²•:

Document ν˜•μ‹μ˜ Content μ˜€λ¦„μ°¨μˆœ, Id λ‚΄λ¦Όμ°¨μˆœμœΌλ‘œ μ •λ ¬ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€. [μ½”λ“œ 보기]

using(var ctx = new ExampleDbContext()){
    var result = ctx.Documents.Sort(nameof(Document.Content)).Sort(nameof(Document.Id), false);
}

κ΄€λ ¨ 링크

GitHub Repository


Profile picture

Pon Cheol Ku (ꡬ본철)

Software developer

Other sites

If does not find interesting topic, you might visit other site on below link.

Β© 2024, Built with Gatsby