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
| /* 채팅방 정보 불러오기 */ | |
| SELECT [채팅방_정보], [채팅방_참여자_정보] | |
| FROM ( | |
| SELECT TOP(1) [채팅방_정보] | |
| FROM [채팅방_테이블] AS [채팅방] | |
| WHERE (( | |
| SELECT COUNT(*) | |
| FROM [채팅방_참여자_테이블] AS [참여자1] | |
| WHERE ([채팅방].[Id] = [참여자1].[채팅방Id]) AND (([참여자1].[챗봇Id] = '챗봇ID') OR ([참여자1].[사용자Id] = '사용자ID'))) = 2) AND (( | |
| SELECT COUNT(*) |
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
| // 채팅방 정보를 가져오기 | |
| var roomId = await database.ChatRoomParticipants | |
| .Where(p => p.ChatbotId == bot.Id || p.UserId == user.Id) | |
| .GroupBy(p => p.RoomId) | |
| .Where(g => g.Count() == 2) | |
| .Select(g => g.Key) | |
| .FirstOrDefaultAsync() ?? await CreateAndGetRoomId(bot, user, database); | |
| // 봇이 참여하고 있는 '채팅방 참여자 정보' 가져오기 | |
| var chatroomParticipantId = await database.ChatRoomParticipants |
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
| /* 채팅방 정보를 가져오기 */ | |
| SELECT TOP(1) 채팅방 참여자 정보 | |
| FROM 채팅방 참여자 정보 테이블 | |
| WHERE (채팅방 참여자 정보의 챗봇 = 사전 정의 된 챗봇) OR (채팅방 참여자 정보 = 요청을 보낸 참여자) | |
| GROUP BY 채팅방 참여자 정보 테이블에 있는 채팅방 ID | |
| HAVING COUNT(*) = 2; | |
| /* 봇이 참여하고 있는 '채팅방 참여자 정보' 가져오기 */ | |
| SELECT TOP(1) 채팅방 참여자 정보 | |
| FROM 채팅방 참여자 정보 테이블 AS [c] |
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
| SELECT 반환될_채팅_메시지_정보 FROM ( | |
| SELECT TOP(50) 채팅_메시지_정보 | |
| FROM [채팅_메시지_테이블] AS [c] | |
| WHERE [c].[채팅방_ID] = (찾을_채팅방_ID) | |
| ORDER BY [c].[전송_시각] DESC | |
| ) AS [t] | |
| LEFT JOIN [채팅방_참여자_정보] AS [c0] ON [t].[채팅방_참여자_정보_ID] = [c0].[Id] | |
| ORDER BY [t].[전송_시각] DESC |
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
| // 이렇게 간단하게 비클러스터형 인덱스를 새로 만들 수 있습니다! | |
| modelBuilder.Entity<채팅_메시지_모델>() | |
| .HasIndex(a => a.인덱스를_걸_프로퍼티) | |
| .IncludeProperties(a => new { a.데이터를_포함할_열들 }); |
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
| /* 위 EF Core 코드가 이렇게 자동으로 쿼리가 만들어집니다. */ | |
| CREATE NONCLUSTERED INDEX_채팅_메시지_채팅방_정보 | |
| ON 채팅_메시지_테이블 ([채팅_메시지_테이블_이름]) | |
| INCLUDE 데이터를_가지고_있어야_되는_테이블_열(들) |
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
| SELECT TOP(50) 채팅_메시지[필요한_열들] | |
| FROM 채팅_메시지_테이블 AS [c] | |
| WHERE c.방_정보 = 정의된_방_정보 | |
| ORDER BY 만들어진_날짜를_기준으로_내림차순으로_정렬 |
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
| // Transaction 내부에 있는 데이터베이스 작업들은 Atomic합니다! | |
| await using (var transaction = await _dbContext.Database.BeginTransactionAsync()) | |
| { | |
| var entity = await _dbContext.AnalysisModels.FindAsync(id); | |
| entity.Field = "test"; // Update | |
| await _dbContext.SaveChangesAsync(); | |
| await transaction.CommitAsync(); // Finish Transaction | |
| } |
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 class Blog | |
| { | |
| public int BlogId { get; set; } | |
| public string Url { get; set; } | |
| [Timestamp] // ROWVERSION | |
| public byte[] Timestamp { get; set; } | |
| } |
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
| [Fact(DisplayName = "SquarePlus: SquarePlus는 ArithmeticRequest의 각 Operand에 2/3을 입력하면, Result로 13을 반환합니다.")] | |
| public void Is_SquarePlus_Returns_ArithmeticResult_With_13_When_Request_Operand_2_3() | |
| { | |
| // Let - 테스트를 하기에 앞서서 입력 / 예상 출력 변수를 정의합니다. | |
| // 이 함수는 객체를 입력으로 받으므로, 객체를 준비합니다. | |
| var request = new ArithmeticRequest | |
| { | |
| FirstOperand = 2, | |
| SecondOperand = 3 | |
| }; |