Пример #1
0
        public static async Task <GetNeutralsReply> GetNeutralsAsync(GetNeutralsRequest request, ServerCallContext context)
        {
            using var db = new LegendaryDatabase();
            var connector = DbConnector.Create(db.Connection, new DbConnectorSettings {
                AutoOpen = true, LazyOpen = true
            });

            var reply = new GetNeutralsReply {
                Status = new Status {
                    Code = 200
                }
            };

            var select = DatabaseDefinition.BuildSelectStatement(request.Fields);
            var joins  = DatabaseDefinition.BuildRequiredJoins(request.Fields);

            var where = !string.IsNullOrWhiteSpace(request.Name) ?
                        $"where { DatabaseDefinition.BuildWhereStatement(NeutralField.NeutralName, DatabaseUtility.GetWhereComparisonType(request.NameMatchStyle))}" :
                        request.NeutralIds.Count() != 0 ?
                        $"where { DatabaseDefinition.BuildWhereStatement(NeutralField.NeutralId, WhereStatementType.Includes)}" :
                        "";

            var whereMatch = !string.IsNullOrWhiteSpace(request.Name) ?
                             new (string, object)[] { (DatabaseDefinition.GetSelectResult(NeutralField.NeutralName), request.NameMatchStyle == NameMatchStyle.Similar ? $"%{request.Name}%" : request.Name) } :
Пример #2
0
        public static async Task <GetHenchmenReply> GetHenchmenAsync(GetHenchmenRequest request, ServerCallContext context)
        {
            using var db = new LegendaryDatabase();
            var connector = DbConnector.Create(db.Connection, new DbConnectorSettings {
                AutoOpen = true, LazyOpen = true
            });

            var reply = new GetHenchmenReply {
                Status = new Status {
                    Code = 200
                }
            };

            if (request.Fields.Count() == 0)
            {
                request.Fields.AddRange(DatabaseDefinition.BasicFields);
            }

            // Need to remove abilityIds field because it's handled separately from the main db request
            var includeAbilityIds = request.Fields.Remove(HenchmanField.HenchmanAbilityIds);

            var select = DatabaseDefinition.BuildSelectStatement(request.Fields);
            var joins  = DatabaseDefinition.BuildRequiredJoins(request.Fields);

            var where = !string.IsNullOrWhiteSpace(request.Name) ?
                        $"where { DatabaseDefinition.BuildWhereStatement(HenchmanField.HenchmanName, DatabaseUtility.GetWhereComparisonType(request.NameMatchStyle))}" :
                        request.HenchmanIds.Count() != 0 ?
                        $"where { DatabaseDefinition.BuildWhereStatement(HenchmanField.HenchmanId, WhereStatementType.Includes)}" :
                        "";

            var whereMatch = !string.IsNullOrWhiteSpace(request.Name) ?
                             new (string, object)[] { (DatabaseDefinition.GetSelectResult(HenchmanField.HenchmanName), request.NameMatchStyle == NameMatchStyle.Similar ? $"%{request.Name}%" : request.Name) } :