For well-to-do Washington doctors, dentists and lawyers, Joseph Keating had a deal.

Buy boxcars, he advised them. Boxcars not only will pay for themselves and make a profit, but also provide a tax shelter enabling the owner to save in taxes two to three times as much as the down payment on a car, he promised.

Lured by the likelihood that their first-year tax refund alone would repay the initial investment, nearly 100 persons - mostly Washington professionals - bought a total of 243 boxcars from Keating's Georgetown company, called Railvest.

Each buyer got a full-sized boxcar that was leased to the Virginia Central Railway of Fredericksburg, a scale model symbolic of the investment and a costly lesson in the pitfalls of off-the-wall business ventures.

Keating's boxcar bonanza has collapsed. The Virginia Central has stopped running, at least temporarily. Railvest has gone out of business. The two companies owe about $500,000 to boxcar owners and other creditors, Keating told Interstate Commerce Commission officials Thursday.

No one is quite sure how much money has been lost. The boxcar buyers still have their freights cars, but many of them have had to make payments of $400 to $500 a month because the cars failed to produce the expected income.

Persons familiar with the business say it failed because neither the boxcar buyers nor Railvest managment understood the complexities of freight car ownership, leasing and accounting.

"Those dentists and doctors don't know a damn thing about business," said one Railvest participant.

"They'd come to meetings and ask the dumbest questions and then never complain when they went for a year without getting financial reports."

An Interstate Commerce Commission official recalled spending three or four hours explaining railroad accounting practices to a young man who turned out to be the chief accountant of Railvest.

"It sounded good, but the managment was poor. It caused the demise of Railvest," said Dr. Frederick Frensilli, a Chevy Chase physician who bought two boxcars.

One of the few boxcar buyers would who would talk about the matter, Dr. Frensilli said he lost money not only on his cars but also on a letter of credit he guaranteed for the company.

Like most car owners, Frensilli has transferred his cars to another management company and, like most, he has given up hope of getting any money from Railvest.

When the company went out of business in February - after a stormy meeting of car owners - it didn't even bother to file of bankruptcy. "The purpose of bankruptcy is to protect the assets of the company. Railvest doesn't have any assest to protect," Keating said in a recent interview.

Keating once owned 70 percent of Railvest's stock, but has relinquished his shares to the other owners to settle one of many lawsuits filed against him and the company.

Mismanagement, waste of the company's assests, illegal use of corporate funds, conflicts of interest involving Railvest officials and failure to pay debts are charged in the lawsuits.

Possible securities fraud and registration violations are being investigated by the Securities and Exchange Commission. The SEC investigation was made public earlier this month when the agency filed a legal action in U.S. District Court for Northern Virginia to force Railvest's general manager, Lawrence Cahill, to testify and produce company records. A hearing on that matter is scheduled Friday.

The ICC has come into the case to try to restore rail service to about a dozen business served by the Virginia Central, a two-mile-long Fredericksburg railroad owned by Railvest. Shutting down the line - in apparent violation of ICC rules - has left the firms with out essential rail service, threatening their survival.

The Virginia Central was an essential element in the boxcar deal, a front company that enabled Railvest to collect higher charges for use of the boxcars. The Virginia Central never had any need itself for the 243 boxcars that Railvest sold and painted with the line's markings. If all the Virginia Central boxcars came home to Fredericksburg at once, they would fill the tracks of the tiny railroad.

The Virginia Central cars were built to be put into the national freight car pool, free to be used by any railroad that needed them and was willing to pay the usual fees to the owner. Under ICC regulations, those user fees under certain circumstances are higher for cars owned by railroads than for cars owned by nonrailroad companies.

Having the Virginia Central's name on the cars instead of Railvest's allowed the cars to earn 66 percent more in user fees. The Virginia Central was supposed to collect the user fees from other railroads, deduct expenses, and pay the earnings to the car owners.

The Virginia Central is not the only railroad run as a vehicle for freight car leasing, National Railway Utilization Corp. has a string of 4,000 cars, many of them baby blue boxcars of the Pickens Railroad, a tiny North Carolina line and the one of five the company owns. Transferred to National Railway Utiliztion and similar companies, the Railvest cars were out of service for some time but are now said to be earning profits.

Perhaps more important than the profits to some boxcar buyers were the tax advantages of boxcar ownership. Several Railvest investors - among them a tax attorney - explained the deal this way:

A new boxcar cost $29.000 to $30,000 and could be bought with a 10 percent down payment ($3,000), with the balance borrowed from a bank. National Bank of Washington financed many of the cars.

Purchase of a new boxcar qualified the buyer for a federal investment tax credit amounting to 10 percent of the car's value, a direct write-off $3,000 - equal to the down payment.

Depreciation also could be deducted from taxes; under the method used by most buyers, that amounted to a $3,000 deduction the first year. In addition-boxcars, which perennially are in short supply, are eligible for a bonus depreciation deduction the first year amounting to $2,000.

Other expenses could be deducted, too: placement fees paid to put the car in service, management fees paid to Railvest and interest on the borrowed money; the total of these deductions varied, depending on when the car was purchased and other factors, but easily amounted to $1,000.

Thus the $3,000 invested in a down payment immediately produced an offsetting tax credit of $3,000 and tax deductions of $6,000. The tax treatment of the boxcar investment has not been challenged by the Internal Revenue Service, several investors said.

The management of Railvest, however, has been challenged in a lawsuit filed by a dissident investor, Georgetown architect Richard Malesardi, who invested $5,000 to buy an interest in Railvest, but never owned a boxcar. In an interview, Malesardi estimated that his experiment in railroading has cost him his original investment, $7,000 he says Keating owes him, $10,000 in legal fees and 500 hours of his time.

Malesardi said the lawsuit was ended by an out-of-court settlement in which Keating agreed to give up any ownership interest in Railvest, among other considerations. Prosecution of the case was futile because Keating has no assets, Malesardi claimed.

The petition filed in Superior Court says Railvest was organized in May 1974 and had about a dozen stockholders, the largest of them Keating. Malesardi was a board member, along with Keating, Washington attorney Donald Seifman, David Salvador, the company's first general manager, and Reynold Sachs, an American University professor.

Describing Railvest as "a service company without assests," Keating said the company "collapsed" because "it lacked the operating capital to continue."

The boxcar buyers "did very well," Keating insisted. "The people that have not done too well are the people who were managing Railvest."

Insisting "we were not doing anything wrong at all," Keating said the company "followed all the rules" of the Securities and Exchange Commission. "They have been trying to find something wrong that we did and they haven't been able to," he asserted.

Quoting minutes of Railvest board meetings, Malesardi's lawsuit says the company's stockholders complained repeatedly about not getting financial reports. A June 1976 board meeting was adjourned when financial data was not available and, more than six months later, in February 1977, the shareholders passed a resolution calling for preparation of a quarterly report to shareholders, a routine document in most corporations.

Within two years of its formation, Railvest was "insolvent or on the verge of insolvency," with liabilties in excess of assets by more than $11,000 and the Virginia Central owing more than $80,000 to the Richmond, Fredericksburg & Potomac Railroad, Malesardi told the court.

In the lawsuit and interviews, Railvest investors said one reason the company failed was that it did not know how much it was costing to manage the boxcars, did not charge the car owners enough to cover the costs, and did not know how much the cars were earning.

Each boxcar ought to have had daily records showing where it was and how much was paid for its use, but instead the monies apparently went into a common account. When the boxcar owners finally decided this February to pull out their cars, they agreed to split the car revenues equally because there were no records to show which cars had earned money and which had not.

Boxcar revenues were used to pay operating expenses of Railvest and to make up the deficit of the Virginia Central, which lost from $1,000 to $3,000 a month, car owners and stockholders contend.

A separate lawsuits, filed by the Richmond, Fredericksburg and Potomac, claims Railvest officials owe that railroad $88,000. The Virginia Central allegedly collected freight bills from its customers but did not pass the money on to the other railroads as it was supposed to.

The railroad has two locomotives, but one of them doesn't run and the other is owned be a Washington physician, Dr. Walter Abendshein, who bought it and leased it to the Virginia Central in a deal arranged by Keating. Dr. Abendshein has told Fredericksburg officials he's supposed to be getting $900 a month forhis locomotive, but hasn't been paid recently.