예제 #1
0
        public TableDataRecord Get(string tableName, string entityId, string uniqueId, IQueryCollection queryParams)
        {
            var io = _engineService.CheckOut();

            try
            {
                io.Connect(DBMS.SQLCompact, _options.ConnectionServer, _options.ConnectionDatabase,
                           _options.DatabaseUsername, _options.DatabasePassword, _options.Trusted);

                var tableMain = io.TableMain.Key.ToLower();

                if (tableName.ToLower() == tableMain)
                {
                    entityId = uniqueId;
                }
                else
                {
                    entityId = _tableDataRecordRepository.SearchEntities(io,
                                                                         $"SELECT {_entityNameLookup[io.ApplicationName]} from {tableName} where idrec = ?", new List <object> {
                        uniqueId
                    })
                               .FirstOrDefault();
                }

                var result = _tableDataRecordRepository.Get(io, tableName, entityId, uniqueId, queryParams);

                _engineService.CheckIn(io);

                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                _engineService.CheckIn(io);

                throw;
            }
        }