This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPatch] | |
public async Task Patch([FromODataUri] int key, Delta<vw_Song> delta) | |
{ | |
var changedProps = delta.GetChangedPropertyNames(); | |
var instance = delta.GetInstance(); | |
var updateDict = new Dictionary<string, object>(); | |
if (changedProps.Contains("Status")) | |
{ | |
updateDict.Add("Status", instance.Status); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (changedProps.Contains("Status")) | |
{ | |
await _db.Country_Songs.Where(i => i.SongId == instance.Id) | |
.UpdateAsync(i => new Country_Songs() { Status = instance.Status }); | |
} | |
if (changedProps.Contains("Field1")) | |
{ | |
await _db.Country_Songs.Where(i => i.SongId == instance.Id) | |
.UpdateAsync(i => new Country_Songs() { Field1 = instance.Field1 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPatch] | |
public async Task<IActionResult> Patch([FromODataUri] int key, Delta<vw_Song> model) | |
{ | |
var instance = model.GetInstance(); | |
var changedProps = model.GetChangedPropertyNames(); | |
if (changedProps.Contains("Status")) | |
{ | |
await _db.Country_Songs.Where(i => i.SongId == instance.Id) | |
.UpdateAsync(i => new Country_Songs() { Status = instance.Status }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE A | |
SET A.[Status] = @zzz_BatchUpdate_0 | |
FROM [Country_Songs] AS A | |
INNER JOIN ( SELECT [c].[SongId], [c].[CountryId], [c].[Status] | |
FROM [Country_Songs] AS [c] | |
WHERE [c].[SongId] = @zzz_BatchUpdate_1 | |
) AS B ON A.[SongId] = B.[SongId] | |
AND A.[CountryId] = B.[CountryId] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE VIEW vw_Songs | |
AS | |
SELECT s.Id, s.Title, MIN(ISNULL(cs.[Status], 0) + 0) CountryStatus | |
FROM Song AS s | |
LEFT JOIN dbo.Country_Songs AS cs ON cs.SongId = s.Id | |
GROUP BY s.Id, s.Title |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public async Task<IActionResult> Post(Entity model) | |
{ | |
_db.Entities.Add(model); | |
await _db.SaveChangesAsync(); | |
return Created(model); | |
} | |
[HttpPatch] | |
public async Task<IActionResult> Patch([FromODataUri] int key, Delta<Entity> model) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
public IEnumerable<Entity> Get(int skip = 0, int take = 10) | |
{ | |
return _db.Entities.Skip(skip).Take(take).ToList(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
... | |
services.Scan(i => | |
i.FromCallingAssembly() | |
.AddClasses(c => c.Where(i => i.IsClass && i.Name.EndsWith("BusinessService"))) | |
.AsImplementedInterfaces() | |
.WithTransientLifetime() | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ApiController] | |
[Route("[controller]")] | |
public class ServiceController : ControllerBase | |
{ | |
private readonly ITransientService _transientService; | |
private readonly IScopedService _scopedService; | |
private readonly ISingletonService _singletonService; | |
public ServiceController(ITransientService transientService, IScopedService scopedService, ISingletonService singletonService) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
... | |
services.Scan(i => | |
i.FromCallingAssembly() | |
.InjectableAttributes() | |
); | |
/* Or */ | |
services.Scan(i => |
NewerOlder