Full download Code First Development with Entity Framework 1st Edition Barskiy pdf docx
Full download Code First Development with Entity Framework 1st Edition Barskiy pdf docx
com
https://ebookname.com/product/code-first-development-with-
entity-framework-1st-edition-barskiy/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookname.com/product/programming-entity-framework-1st-
edition-julia-lerman/
ebookname.com
https://ebookname.com/product/eclipse-development-using-the-graphical-
editing-framework-and-the-eclipse-modeling-framework-1st-edition-bill-
moore/
ebookname.com
https://ebookname.com/product/reverse-engineering-code-with-ida-
pro-1st-edition-ioactive/
ebookname.com
https://ebookname.com/product/platonism-naturalism-and-mathematical-
knowledge-1st-edition-james-robert-brown/
ebookname.com
https://ebookname.com/product/mediterranean-wooden-shipbuilding-
apostolos-delis/
ebookname.com
https://ebookname.com/product/developmental-psychology-childhood-and-
adolescence-seventh-edition-david-shaffer/
ebookname.com
Learning iPhone Programming From Xcode to App Store 1st
Edition Alasdair Allan
https://ebookname.com/product/learning-iphone-programming-from-xcode-
to-app-store-1st-edition-alasdair-allan/
ebookname.com
Code-First Development
with Entity Framework
Sergey Barskiy
BIRMINGHAM - MUMBAI
Code-First Development with Entity Framework
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book
is sold without warranty, either express or implied. Neither the author nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78439-627-5
www.packtpub.com
Credits
Reviewers Proofreaders
Erik Ejlskov Jensen Maria Gould
Andriy Svyryd Elinor Perry-Smith
Technical Editor
Narsimha Pai
Copy Editor
Deepa Nambiar
About the Author
Sergey Barskiy has been using Entity Framework since it was first released to
the public. He has deployed a number of projects to production that used Entity
Framework over the years. He has used the Code-First approach on a few different
projects as well. Sergey has produced an online video training course for this
technology. He has spoken on Entity Framework Code-First at a number of
national and regional conferences and events.
Erik Ejlskov Jensen is a Danish .NET developer who specializes in .NET data
development. He is a Microsoft MVP for SQL Server and shares tips and code via
his blog at http://erikej.blogspot.com and Twitter at @ErikEJ. He is a project
manager for a number of SQL Server Compact and SQLite tools on the Codeplex site,
and he is the creator of the popular free Visual Studio add-in SQL Server Compact/
SQLite Toolbox. He also contributes to a number of open source projects, including
Entity Framework.
Andriy Svyryd was born in Ukraine, and then he moved to Mexico, where he
graduated from Universidad Nacional Autónoma de México (UNAM). His first job
was at Microsoft, where he worked on several projects related to data modeling.
He was a developer on the Entity Framework team for 4 years.
www.PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.com
and as a print book customer, you are entitled to a discount on the eBook copy. Get in
touch with us at service@packtpub.com for more details.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
[i]
Table of Contents
Self-test questions 44
Summary 45
Chapter 4: Querying, Inserting, Updating, and Deleting Data 47
The basics of LINQ 47
Filtering data in queries 49
Sorting data in queries 51
Exploring LINQ functions 52
Element operations 52
Quantifiers 53
Working with related entities 54
Filtering based on related data 54
Lazy and eager loading 55
Inserting data into the database 57
Updating data in the database 60
Deleting data from the database 65
Working with in-memory data 67
Self-test questions 69
Summary 70
Chapter 5: Advanced Modeling and Querying Techniques 73
Advanced modeling techniques 74
Complex types 74
Using an explicit table and column mappings 77
Adding supporting columns 78
Enumerations 79
Using multiple tables for a single entity 80
Advanced querying techniques 83
Projections 83
Aggregations and grouping 88
Advanced query construction 89
Paging data with windowing functions 92
Using joins 93
Groupings and left outer joins 95
Set operations 101
Self-test questions 102
Summary 104
[ ii ]
Table of Contents
[ iii ]
Preface
Preface
I have been writing applications on the Microsoft platform for almost 2 decades.
Many, if not all of them, use databases to persist user data. I have used many
technologies to access data, starting with ADO.NET. Object Relational Mapping
(ORM) tools, have many advantages over ADO.NET. They allow developers to
write data access code faster and safer. ORM tools have been designed to solve
impedance mismatch problems between object-oriented programming and relational
databases. Microsoft's Entity Framework is the company's answer to the demand for
an ORM from .NET developers. This book is the guide that will help you acquire the
necessary skills to program your applications using Entity Framework.
This book centers on the Code-First approach with Entity Framework, which
has become the most common way of using the technology. Code-First allows
developers to control the entire data access layer of their applications from the .NET
code. This approach simplifies and streamlines the entire application development
life cycle, keeping developers coding inside Visual Studio, the only tool they need to
use Entity Framework.
The books starts with the basic concepts of defining the database structure via C#
and VB.NET code, then progresses to full data access. Chapters cover create, read,
update, and delete operations (CRUD) with Entity Framework. It also shows how
to update the Relational Database Management System, (RDBMS) structure, via
the migrations API. It explores aspects of data access in both .NET languages using
the Languages INtegration Query (LINQ), API. Because of Microsoft's continuous
commitment to both C# and VB.NET, the book contains examples in both languages
in every chapter.
[v]
Preface
I have been using Entity Framework since 2008, and I felt that I had the necessary
experience to write a book on the subject. I spoke on the topic on many conferences
and events and saw tremendous interest in creating a concise guide to Entity
Framework. This was one of my primary motivations in creating a shorter textbook.
I read many technical books while working in the industry, and I myself, at times,
had trouble maintaining the focus while reading 800-page technical books. They
definitely have a place in the industry and are very useful. However, I feel they
are intimidating for the developers who are just getting started with a particular
technology. My hope is that this book will get you going quickly on the new topic
and have you writing data access code in a few hours. You should be able to master
the foundation behind Entity Framework with this book quickly and easily.
Chapter 2, Your First Entity Framework Application, teaches us how to create our first
project that uses Entity Framework. We create classes that map to database tables.
We observe how our target database is created when the project is run. Finally, we
save and retrieve our first data from the created database.
Chapter 3, Defining the Database Structure, dives deep into details of mappings
between classes and tables. We create maps between properties to columns as well
as rules that govern such mappings. We define relationships between classes that
translate into relationships between tables. We exercise multiple approaches that
can be used to define the mappings.
Chapter 4, Querying, Inserting, Updating, and Deleting Data, discusses how to use the
LINQ API, that allows developers to retrieve the data from the database. We sort,
filter, and perform element operations and use quantifiers. We query related entities.
You learn the advantages and pitfalls of eager and lazy loading. We insert, delete,
and update the data.
Chapter 5, Advanced Modeling and Querying Techniques, dives deeper into modeling
and querying techniques. We use complex types to have more consistency in the
database structures. We create an explicit table and column names. We define
structures that use table and entity splitting. We use projections in queries to
make them more efficient and summarize our data. We page the data for retrieval,
breaking it up for presentation to the users. We use joins to create queries that use
related entities.
[ vi ]
Preface
Chapter 6, Working with Views, Stored Procedures, the Asynchronous API, and
Concurrency, shows how to access with database views from Entity Framework.
We query data via stored procedures using the Entity Framework API. We perform
create, update, and delete operations with stored procedures. We exercise Entity
Frameworks and the asynchronous API and learn the advantages and pitfalls
of asynchronicity. We implement concurrency handling, learning to handle the
situation when multiple users attempt to update the dame data.
Appendix, Answers to Self-test Questions, contains answers to questions you will find
throughout the book.
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
[ vii ]
Preface
Code words in text, database table names, user input are shown as follows:
"You also need at least one class that represents the database itself, which will
inherit from DbContext."
Any command-line input or output is written as follows. "If we need to get detailed
help for the PowerShell commandlet Enable-Migrations, we just need to type Get-
Help Enable-Migrations."
New terms and important words are shown in bold. Words that you see on the
screen, in menus or dialog boxes for example, appear in the text like this: "clicking
the Next button moves you to the next screen".
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it
helps us develop titles that you will really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide at http://www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
[ viii ]
Preface
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.
[ ix ]
Chapter 1
What is ORM?
When it comes to business software, almost all of it needs to store data that pertains to
its functions. For many decades, Relational Database Management System (RDBMS)
has been a go-to data storage for developers. ORM is a set of technologies that allows
developers to access RDBMS data from an object-oriented programming language.
There are other RDBMSes available, such as SQL Server, Oracle, DB2, MySQL, and
many more. These database systems share some common characteristics. Each system
supports one or more databases. Databases consist of many tables. Each table stores
data in a tabular format, divided into columns and rows. Data rows in multiple tables
may relate to each other. For example, a person's details stored in the Person table can
have phone numbers stored in a separate Phones table.
[1]
Introducing Entity Framework
In the following screenshot, you can see a table that allows you to store a person's
information, specifically their first and last names, along with a unique identifier for
each person. This type of storage, where similar data items are grouped together into
tabular structures is typical:
Each column can also be constrained in some ways. For example, PersonId is an
integer column. LastName is nvarchar(50) column, which means you can store
Unicode data of variable size in it, up to 50 characters. You will see in subsequent
chapters how we describe this information using Entity Framework.
The data stored in each column and row combination is scalar data, such as number
or string. When software needs to persist or retrieve data, it must describe its intent,
such as insert or select query, using the database-specific language called Structured
Query Language (SQL). SQL is a common standard for all relational database systems,
as issued by the American National Standards Institute (ANSI). However, some
database systems have their own dialect on top of the common standard. In this book,
we are not going to dive into the depths of SQL, but some concepts are important
to understand. There are some basic commands that we need to look at. These are
typically described as CRUD. CRUD stands for Create, Retrieve, Update, and Delete.
For example, if you want to retrieve or query the data from the preceding example,
you would type the following:
SELECT PersonId, FirstName, LastName
FROM Person
[2]
Chapter 1
For example, if we change the column name in our database from FirstName to
First_Name, our code would still compile just fine, but would throw an exception
when we try to run it. Moreover, the data in the database was stored as scalar values
organized in columns and rows in a table, but our destination was an object or object
graph. As you can see, this way of accessing the data has a number of issues.
First of all, there is a type mismatch between RDBMS column types and .NET
types. Second, there is a mismatch between storage, which is a collection of scalar
values, and destination, which is an object with properties. To further complicate
the situation, our person object could also have a complex property that contains
a list of phone numbers, which would be represented by a completely different
table. These problems are collectively referred to as impedance mismatch between
object-oriented programming and relational databases.
The set of tools called ORM came about to solve this mismatch problem. An ORM
tool represents data stored in database tables as objects, native to a programming
language, such as .NET languages, C#, and VB.NET. ORM tools have many
advantages over the traditional code, such as ADO.NET code that we mentioned.
They expose the data using native .NET types. They expose related data using simple
.NET properties. They provide compile time checking. They solve the problem with
typos. Developers do not have to use SQL, a different language. Instead in the .NET
world, developers use Language INtegrated Query (LINQ) to query the data. LINQ
is simply part of C# and VB.NET languages. We will cover the basics of LINQ in
subsequent chapters. By the same token, programmers use an ORM tool's API to
persist data to the database. Finally, as we will see later, you will write less code.
Less code means fewer bugs, right?
[3]
Introducing Entity Framework
Entity Framework went through a few revisions. In the first version, only Database First
approach was supported. What this meant was that you would point the designer to
an existing database. As a result, code was generated that would contain a database
and table abstractions. In addition to the code, an EDMX file was also created. This
XML file contained Entity Data Model. It consisted of three models: logical, storage,
and mapping. The logical, sometimes called conceptual, model is the one you will code
against in C# or VB.NET. Storage model describes how data is stored in a database.
The mapping model, as the name implies, provides the mapping between logical and
storage models. If you were to change anything in the database, you would need to
refresh the generated model. The C# or VB.NET code is also generated again. The
mapping model has a class based on ObjectContext that has collection properties for
each table in the database. Each collection is a generic collection, where collection item
type is inherited from a base class in Entity Framework. Each class has properties that
correspond to columns in the matching table.
Finally, the Entity Framework Code-First approach was shipped in version 4.1. This
approach eliminated the need for the EDMX file. It also eliminated the dependency
on Entity Framework base classes that each entity in the model inherited from. As a
result, the code became more testable. This approach also eliminated the need for the
designer. You could just type your classes, and they would automatically be mapped
to tables in the database. There have been subsequent Entity Framework Code-First
releases after the the initial 4.1 version.
[4]
Chapter 1
Once this structure is laid out, you are capable of querying the underlying database
by using LINQ queries. If you add a brand new instance of the TRowType class to its
parent collection and then save the changes using the DbContext API, this new object
will become a row in the corresponding table, where each property value of that object
will become a column value in the target row. On top of this, Entity Framework has
capabilities to represent other database artifacts, such as procedures and functions.
You will be able to query the data using functions, just like tables using LINQ again.
The question of evolving the database structure is an important one. In most cases, you
will need to add columns and tables, as your application changes. Entity Framework
addresses this need via the Migrations feature. This ability will allow you to alter
the database structure through C# code. In addition to adding and deleting tables
and columns, you will be able to add indexes. Migrations allow developers to evolve
a schema without data loss. As you can see, Entity Framework exposes everything
you need to access the data in your C# or VB.NET code without wiring SQL and
treats your database as another part of your overall application code. You can check
migrations code into source control, since it is also C# code!
[5]
Introducing Entity Framework
Self-test questions
Q1. Which of these problems does an ORM tool solve?
Q2. Developers must write SQL queries to work with Entity Framework. True or false?
Q3. What is the name of the technology that Entity framework uses to apply
structural changes to the target database?
1. Updates
2. Conversions
3. Migrations
Q4. Which is the key class that represents database abstraction with the Entity
Framework Code-First approach?
1. DbContext
2. ObjectContext
3. DataContext
Q5. Entity Framework can only work with Microsoft databases, such as SQL Server.
True or false?
Summary
In this chapter, we took a look at how data is stored in RDBMS systems. We saw the
shortcomings of using embedded SQL to access the data. We understood what ORM
tools are all about and what problems they solve. We examined the history behind
Entity Framework. We saw the capabilities of Entity Framework. Finally, we had a
brief excursion into the Entity Framework architecture.
In the next chapter, we will actually build our first application based on Entity
Framework Code-First.
[6]
Chapter 2
[7]
Your First Entity Framework Application
[8]
Other documents randomly have
different content
The Project Gutenberg eBook of Preview of
Peril
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: English
Introductions were short and to the point. Most of the ship's officers
had met Hartnett's staff at the Base Officer's Club after the Captain's
Council, where the commanders of the four ships that made up
Flotilla Blue Three had met their Commodore for the first time. Scott
sighed as he thought of the evident relief on Lieutenant Morrow's
face when he had found that the flagship was to be the Darkside
and not his own ship, the Lysander.
"That Hartnett will take over your ship, Scott," Morrow had told him.
"He can't help it. From the moment he steps aboard, it'll be his
baby." And Hartnett was a gambler....
Scott presented his officers to the Commodore almost jealously,
starting with the Executive, Lieutenant Commander Chavez and
Lieutenant Horowitz, the Tactical Physicist; and ending up with
Ensign Blake, the Junior Gunnery Officer, who was startled from his
nervous fidgeting by the sound of his name.
"A reservist," was Hartnett's only comment, and though it was said
in a friendly tone, Blake flushed furiously and wondered if it stuck
like straw out of his ears.
"Mr. Blake is the Charles Blake who won the New York to Ley City
amateur skeeter-boat race last year, Sir," explained Scott.
The Commodore nodded vaguely, his eyes wandering over the
burnished chrome and steel of the Control panels. "Good sport,
small ship racing, Mr. Blake," he commented.
Blake's cherubic face burst into smiles. "The best sir!"
Hartnett's men were presented to the ship's commander more as a
formality than anything else, as he had met them before. Thorne, a
full Commander, was Flotilla Astrogator, Wilson and Orsov,
Lieutenants, were Flotilla Gunnery Officers, James, a jaygee, was
Flotilla Signals Officer, and Ensign Ward, a thin boy about Blake's
age, was the Commodore's Aide. He sported his single silver
augilette proudly.
They didn't seem a bad lot, reflected Scott grudgingly. Maybe they
wouldn't get in the way too much.
"We can lift ship as soon as convenient, Mr. Scott," said Hartnett,
issuing his first order.
"Aye, sir."
Hartnett turned to his staff. "Get yourselves below and sort
yourselves out. Try not to take up too much room." As they vanished
down the ramp, he turned to take a seat at the visiplates.
Scott was taking a time check from the Tower Control, and the
signalmen were relaying the lift-ship order to the three other ships of
Blue Three. Outside on the airless field, the amber warning lights
were spinning on the Tower mast, warning the spacesuited
maintenance crews away from the blast pits.
Chavez was snapping orders into the intercom and the Darkside was
awaking to activity smoothly. Five shielded decks below Control,
Chief Jetman Collins and the black-gang were busily removing the
seals from the cadmium dampers in the blast chambers. The "three-
minutes-to-lift-ship" alarm blared and the lights dimmed, leaving
Control lighted only by the reflected glow of the panel lights. On the
visiplate screen, the slender shapes of the Lysander, the Argus and
the fat, ungainly silhouette of the ironically named Artemis showed
clearly in the earthlight.
The Artemis, thought Hartnett, was the only weak link in his
command. The other three ships were modern, but the Artemis was
an ancient alcohol burner, converted to atomics and pressed into
service by the exigencies of an undeclared and treacherous war.
At best, she could stand no more than 5 Terran Gs and the rest of
the Flotilla would be forced to keep to her reduced speed throughout
the cruise. Her armament was lighter and her armor thinner than it
should be. In fact, she was strictly Cat meat if she should ever be
forced to stand and fight. And if they intercepted any Cats, that is
exactly what she would have to do, since she was the only ship of
Blue Three that could not outrun any comparable Martian ship.
Scott was giving his orders now, eyes fastened on the master
chronometer. Hartnett was pleased to see that he did so without a
sidelong look at his superior. He knew his business and did it. Good.
Then Hartnett could stick to handling Blue Three and worrying about
the Artemis without thought of how the ship under him was being
managed.
He slipped into his G-Suit and plugged the lines into an outlet on the
side of his chair. The second hand swept up the face of the dial, and
Scott hit the firing studs. Far below, Jetman Collins removed the
dampers from the main blast chambers.
The takeoff was strictly routine for the Luna Base personnel. The
four ships of the Flotilla rose from the pits on their long tails of
radioactive flame, setting the outside Geiger counters to clucking
wildly and outlining in vivid relief the three dreadnaughts that lay in
their careening berths and the dozen or so smaller ships on the line.
Under 3 Terran Gs of acceleration, Flotilla Blue Three was soon lost
in the ebony sky. For just an instant there was the vaguest
suggestion of four racing shadows on the blue-green disk of the
gibbous Terra that hung low in the heavens, and then nothing. The
airless silence of Luna Base continued unbroken.
In the sheathed Control Tower, the Operations Officer made ready to
go off watch. He was thinking of a few drinks and a girl and maybe a
thick steak down in Ley City. Wonderful place, Ley City ... even in
wartime.
The door burst open, but it was not his relief. It was a breathless
yeoman of signals. He held a sheaf of papers in his hand.
"Has Blue Three lifted, sir? Cryptographing sent me with this."
"Damn! They're well out by this time Reilly." He indicated the radar
screen that showed four rapidly moving pips already heading into
deep space.
The yeoman handed him the papers without a word.
"What kept you?" The officer demanded angrily.
Reilly looked at his superior reproachfully. "I made it from Crypto in
forty seconds flat, sir. Couldn't come any faster!"
"Dammit! Now we'll have to put this on tight beam and scramble it.
Intelligence suspects the Cats have cracked our cipher!"
He sat down at the scrambler and began to type.
"COMMODORE CLARE HARTNETT: ABOARD TRS
DARKSIDE FLOTILLA BLUE THREE. PRIORITY MISSION.
REPEAT. PRIORITY MISSION. SPATIAL INTELLIGENCE
REPORTS LARGE QUANTITY ISOTOPE X-R REFERENCE
6589-3 CODE BOOK IN DANGER OF CAPTURE AT
METALLURGICAL STATION 9 CHART REFERENCE A-5.
PREVENT AT ALL COSTS. LARGE CONCENTRATION
MARTIAN PHOBOS CLASS CRUISERS AND POSSIBLE
SUPERDREADNAUGHT ARMED WITH CYCLOTRONICS IN
VICINITY SEARCHING FOR STATION 9. REPEAT. X-R
MUST NOT FALL INTO MARTIAN HANDS. DESTROY IF
NECESSARY. FOR YOUR INFORMATION AND GUIDANCE
INTELLIGENCE SUSPECTS CIPHER TWO HAS BEEN
CRACKED BY MARTIAN CRYPTO. LUCK. DO NOT
ACKNOWLEDGE. SIGNED: TORAN LONG, CAPTAIN,
SENIOR CONTROL, LUNA BASE. END MESSAGE."
Rising, he detached the roll of perforated tape from the scrambler
and fed it into the tight beam transmitter. When the roll was
consumed, Long dropped sullenly into a chair. His relief arrived, but
all desire to partake of the joys of Ley City was gone. Like most of
the old timers he admired Hartnett immensely, and he could not rid
himself of the feeling that he was in some way responsible for
sending the fabulous spaceman into sure destruction.
Against the ten known cruisers and the suspected superdreadnaught
that were searching that quadrant for the illusive Station 9, the
strength of Flotilla Blue Three was sadly inadequate.
If the message had arrived earlier, a dreadnaught or at least a
couple of cruisers could have been despatched with Hartnett's force.
But the impossibility of a rendezvous in space made it strictly the
Commodore's baby now. Besides, Terra had no ships to spare.
Hartnett would have to rescue the three technicians at the Station
and destroy the Isotope X-R with no help.
The Cats didn't know what X-R was, but they wanted to find out
awfully badly if their concentration of strength in the Uranus
quadrant was any indication. And it wouldn't be very long before
they found that the mysterious Station 9 was on Oberon, either. With
more than eleven ships prowling around, they wouldn't miss such an
obvious bet for very much longer. All Hartnett had to do now was
sneak through their screen, land a ship on Oberon, take the
technicians off, destroy the X-R, and get away again without being
seen because the Artemis couldn't fight! Long groaned. That's all!
Oh, why, he wondered, wouldn't Terrans learn? An ancient leader of
Terra's nationalist era had said it perfectly for them. Speak softly, he
had said, but carry a big stick! Why wouldn't they listen?
He shook his head and left the Control Tower wearily.
"What's eating him?" asked the relief.
"He's just sent Blue Three into the Uranus quadrant," replied Reilly.
The relief gave a low whistle and turned to look out over the earthlit
moonscape. "Too bad."
Hartnett caught the Commander's eye as he worked at the control
board.
"Sorry to crowd you like this, Mr. Scott," he said.
"It's nothing at all, sir. It's a pleasure to have you aboard." Even as
he said it, Scott realized how stupid it must sound. Of course it
crowded him to have Hartnett aboard and it annoyed him being the
second ranking officer on his own ship.
Commodore Hartnett smiled at the Commander's words. There was
hardly anything else he could say, poor devil. Rank has its privileges,
he thought. But he said: "Glad you feel that way," and fell silent
watching Scott and the Quartermaster guide the ship through the
first stages of acceleration.
Scott felt he should say something more, but he wasn't at all sure
just what. Finally he said, "We've only an hour or so more of
acceleration, sir. If there's anything you want tied down in your
cabin, you'd best notify Mr. Ward. The Darkside has no gravitators."
"The cabin will be in order, Mr. Scott," replied Hartnett casually, "My
staff and I are all destroyer men."
Scott cursed himself for an idiot and mumbled an apology, but the
Commodore had let the incident pass with a half hidden smile and
was inspecting the orbital calculators at the far wing of the Control
panel.
The voice of Lieutenant Morse, Astrogation Officer, saved Scott any
further embarassment. The communicator buzzed and Scott closed
the switch.
"Control here!" he snapped, a bit too crisply.
"Astrogation. We'll be at the boundary of our inner patrol zone at
2335 Sidereal, sir."
Scott looked over at Hartnett. "Any orders, sir?"
The Commodore shook his head. "Just have the other ships maintain
visual contact. Particularly the Artemis. The Lysander can take the
rear position. Have me called in my cabin if anything comes up
before then. See you in the wardroom at dinner. Carry on, Mr. Scott."
He left Scott feeling sorry for his friend, Tom Drew, who commanded
Blue Three's lame duck, the beloved Artemis.
Striding down the ramp, the Commodore came to the main gun-deck
and headed aft, past the banks of five inchers and torpedo tubes
that lined the inner shell. The gun crews stood respectfully as he
walked past them and returned young Blake's sharp salute. Hartnett
restrained a smile and continued down to the cabin deck.
Ensign Ward was unpacking his gear as he came through the valve,
and listening to a commercial broadcast on short wave that crackled
and faded with the vagaries of Terra's faraway heavyside layer. The
reports, pieced together, gave a fairly comprehensive picture of the
fighting that was going on in the Uranian quadrant.
"I don't like the way things are going, sir," said Ward.
Hartnett didn't either, but he could see no point in saying so.
Besides, the Flotilla's patrol area was on the other side of the sun
from Uranus, and the news there was bad enough to give him food
for thought.
"I won't need you for a bit, Ward. Take off and get yourself settled,"
he suggested.
The aide saluted and left. Hartnett stripped off his blouse and shirt
and settled himself comfortably on the acceleration bunk. He
switched on the bank of solar lamps and let the warm rays sooth
and relax his tired muscles. The tension of many harrowing days in
the Pentagon began to leave him, and he felt a great pity for the
desk-bound VIP who could not know the joy of a ship under them in
deep space. Thank God he got past the last physical. They were
getting tougher every patrol!
The radio was still on and as the news reports came in, his restless
mind turned to consider the unfortunate tactical situation in which
the Terran Space Force now found itself.
It was the old democratic failing. God Bless it! As old as Terra's
history. Ship for ship and man for man the Terran Forces were better
than the Martian. Terrans shot faster and straighter. Terran ships
flew farther and faster. And Terra, for all its failings, was a free world
fighting for a free space. But the Cats had more ships and a hell of a
lot less reluctance about using them to enslave everybody in sight.
Scott paced furiously up and down the steel deck of the dark
Control. Chavez sat before the panels, his saturnine face wreathed in
demon-like curls of blue smoke from the short, black, Mexican
cheroot he smoked so lovingly.
"You should have heard him!" exclaimed Scott, "Standing there and
calmly telling us that we are going to destroy the Cat fleet with the
Artemis! Booby trap 'em, he says! Chav, I tell you he's gone looney!"
Chavez shrugged and smoothed his hairline moustache. "Quien
sabe?"
"What the hell do you mean 'Quien sabe!' Are you trying to tell me
you're thinking he can do it?"
The Latin smiled, showing animal white teeth. "I understand he's
done a lot of things that people said weren't possible. Personally, I
should be very glad if he did what he says so we could all get back
to Ley City. Amigo, I have a little friend back on Luna that is." He
smiled dreamily and kissed his fingertips.
"I think you're all going crazy. It's just having that man aboard."
"Ah, Ah!" cautioned Chavez, "Remember all those beautiful silver
stripes."
"Well, damn the lot of you. I just hope we get the Darkside back to
Luna Base and your little...." He made an angry parody of Chavez's
romantic gesture.
"We'll get back, I think, Mr. Scott," said a casual voice from the
Valve. The Commodore was standing in the arch, outlined against
the ramp light. He stepped into Control and took a seat beside
Chavez at the panels.
Scott and Chavez maintained an embarrassed silence. Hartnett
looked up to study the now receding solar disk through the tinted
visiplate. The Flotilla was now heading once again for deep space.
It was a few moments before Hartnett spoke. When he did, it was a
command directed at Scott.
"Mr. Scott, the Flotilla will land for certain necessary readjustments
on Hyperion. See that the other vessels are properly notified." Then
he rose and left the Control.
Scott dropped unhappily into a chair. He looked at Chavez. "Well, Mr.
Chavez. How do you think you will enjoy command of the Darkside?"
Chavez laid a friendly hand on his commander's sleeve. "I don't think
he'd take your ship from you just because...."
"Skip it, Chav!" snapped Scott and he left the Control in peevish
silence.
Sixty hours later Blue Three lay grounded in a jagged little valley on
airless Hyperion. Spacesuited figures swarmed about the clustered
ships transferring personnel from the Artemis to the other ships, and
rigging special television, remote control, and other apparatus in the
Artemis.
Hartnett stood beneath the Darkside's ventral valve on the metallic
soil of the little moon with Chavez and Orsov watching the progress
of the work. Lieutenant Morrow of the Lysander and Lieutenant
Griggs of the Argus joined them and stood in silence while the last of
the Artemis' personnel was transferred into the Darkside. Tom Drew,
the commander of the Artemis stood sadly apart watching the
spacemen make a ghost ship of his command.
On the eastern horizon, Saturn was rising into a black sky studded
with points of fiery brilliance. Quickly the ringed planet climbed into
the sky and flooded the tortured landscape of Hyperion with light.
The men at the Darkside's valve stood watching the show of celestial
grandeur in awe. Orsov, for all his deep-space experience, could not
help but feel a twinge of vertigo as he looked up into the haloed face
of the heavenly giant that filled a quarter of the inverted bowl of
ebony that the heavens had become.
Everyone was relieved to lift ship, however, for the thought of being
caught grounded by any roving Martian spaceship was not pleasant
to contemplate. Atomic bombs had long been obsolete, but one such
would certainly suffice to exterminate four grounded spacecraft.
Then too, they were all glad to get away from the glaring spectre
that so eerily filled too much of the sky ... the ringed Saturn had a
hypnotic effect that left a man shaken.
In the Control of the Darkside Chavez whispered to Scott: "We were
thinking that you were going to lose the Darky ... and it turns out
that poor old Drew is the one who lost his command."
"He should be glad to get rid of it."
"But what," asked Chavez, "is the old man going to do with her?"
Scott shrugged and spoke succinctly. "Bait." His spirits had risen
considerably when Hartnett had left him in command of the
Darkside, contrary to his expectations. He reflected somewhat
ruefully that it did a man good to have a scare thrown into him from
time to time. Even now, rapidly approaching a quadrant heavy with
Cat warships, he could feel contented in merely feeling his beloved
tin can responding under his hands on the control panels.
A thousand yards behind and astern, the unmanned Artemis
followed the Darkside like a dog on a leash, its myriad functions
controlled by an invisible chain of subetheric impulses from jerry-
rigged remote controls on the Darkside's gun-deck.
In the faint light of the faraway sun, where the irrepressible Blake
had sloshed paint on her flank, gleamed the legend: BOOBY TRAP.
Like shadows, the four ships of Flotilla Blue Three slipped through
the patrol cordons of the Martian Space Force. In the infinite
vastnesses of the interplanetary deeps they were unnoticed. Blast
tubes silent, guided only by the ever increasing gravitational
attraction of mammoth Uranus, and the reaction of whining
gyroscopes.
Beneath them, its greenish disk ever increasing, lay Uranus ... cold,
harsh, forbidding. The thick atmosphere of methane and ammonia
lay in great turbulent belts, whipped to maniacal fury by the eternal
storms that swept the unguessable surface of the ghastly planet.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com