
272 S.W.3d 336 (2008)
STATE of Missouri ex rel. AMERICAN EAGLE WASTE INDUSTRIES, et al., Appellants,
v.
ST. LOUIS COUNTY, Missouri, et al., Respondents.
No. ED 91677.
Missouri Court of Appeals, Eastern District, Division Five.
October 21, 2008.
Motion for Rehearing and/or Transfer to Supreme Court Denied December 9, 2008.
Application for Transfer Denied January 27, 2009.
*338 Jane E. Dueker, John R. Phillips, Tricia A. Workman, St. Louis, MO for appellants.
Patricia Redington, Robert H. Grant, Clayton, MO, for respondents.
KENNETH M. ROMINES, Judge.

Introduction
A group of private trash and waste collectors ("Haulers") operating businesses in St. Louis County appeal the judgment of the Circuit Court of St. Louis County, the Honorable Steven H. Goldman, presiding, dismissing their claim against St. Louis County ("the County") for a writ of mandamus and declaratory judgment. Haulers claimed the County improperly commenced waste collection throughout St. Louis County without providing notice to Haulers, in violation of section 260.247, RSMo. (Supp.2007), and the County argued it had constitutional authority to take precedence over the statute due to its status as a charter county with home rule. Because we find that the trial court improperly dismissed Haulers' case for failure to state a claim, we reverse and remand.

Factual and Procedural Background
This is an appeal from the court's dismissal for failure to state a claim, and therefore we take all facts alleged in the petition as true. Rosenfeld v. Thoele, 28 S.W.3d 446, 449 (Mo.App. E.D.2000). The facts set out in Haulers' petition are as follows.
In December 2006, St. Louis County, a charter county under Missouri Constitution article VI, section 18, changed its code to enable the County to establish trash collection districts and commence trash collection responsibilities. At the time, private hauling companies, including Haulers, provided waste collection services throughout St. Louis County. After the change took effect, the County requested bids to contract with trash collection companies for each newly-established trash district. In April 2008, the County awarded a contract to Veolia ES Solid Waste Management, LLC ("Veolia"), for waste collection services in one of the trash districts, to begin 1 July 2008. The County invited bids in the following months for the remaining districts. The County was set to begin trash collection in those districts, through its contractors, on 1 October 2008.
In June 2007, after the County had changed its code but before it had accepted any bids, the Missouri General Assembly approved an amendment to section 260.247, RSMo. (2000). That section formerly provided that, in the event a city commences solid waste collection, the city must give companies currently providing collection services notice before doing so. Additionally, the statute provided a two-year waiting period once the city gave notice before it could commence trash collection services, unless the city chose to contract with the private companies providing collection services at the time. Section 260.247.2. The 2007 amendment expanded the reach of the statute to "[a]ny city or political subdivision" intending to enter into waste collection. Section 260.247.2 (Supp.2007). The amendment became effective on 1 January 2008, before the County accepted any bid proposals.
Haulers filed a petition for writ of mandamus in the Circuit Court of St. Louis County on 29 May 2008, asking the court to order the County to abide by section 260.247's notice requirement because the County was a "political subdivision" under the statute. The trial court denied Haulers' writ petition that same day. Haulers' petition contained an alternative count for declaratory judgment, and on 12 June 2008, the County filed a motion to dismiss *339 proffering two grounds: 1) failure to state a claim, arguing that the County's status as a charter county meant Section 260.247 did not apply to the County, and 2) failure to join indispensable parties. Both parties filed memoranda of law,[1] and the trial court entered a judgment granting the County's motion to dismiss on 25 June 2008. In that judgment, the court analyzed whether Section 260.247 applied to the County's actions, determined it did not, and held that Haulers had failed to state a claim. Haulers appeal.

Jurisdiction

Writ of Mandamus
The parties dispute the threshold question of whether this Court has jurisdiction to review the denial of Haulers' petition for a writ of mandamus.
The general rule is that no appeal lies from the dismissal or the denial of a petition for writ of mandamus. See Harkins v. Mitchell, 911 S.W.2d 689, 690 (Mo. App. E.D.1995) (holding no appeal permitted from dismissal of writ petition); State ex rel. Ashby Road Partners, LLC v. State Tax Comm'n, ___ S.W.3d ___, 2008 WL 2491956 (Mo.App. W.D. June 24, 2008) (same regarding denial of petition for alternative writ), cause ordered transferred (30 Sept. 2008). The remedy in such a case is a direct petition for writ of mandamus in a higher court. Id. Conversely, if an alternative (or preliminary) writ issues and subsequently the court quashes it and denies the peremptory (or permanent) writ, we may review that decision. See, e.g., State ex rel. Stoecker v. Director of Revenue, 734 S.W.2d 263 (Mo.App. E.D. 1997).
Nevertheless, appellate courts have reviewed dismissals of alternative writ petitions when the trial court actually ruled on the meritswhere, for example, the respondent answered the petition on the merits, and the trial court considered the merits in dismissing the petition, Jones v. Jackson County Circuit Court, 162 S.W.3d 53, 57-58 (Mo.App. W.D.2005); where the respondent answered and the trial court decided the legal question regarding the sufficiency of the allegations, State ex rel. Schaefer v. Cleveland, 847 S.W.2d 867, 870 (Mo.App. E.D.1992); and, in at least one instance, a court treated a dismissal as though a preliminary writ had been granted and quashed when the respondent answered on the merits and the trial court addressed a question of law, Wheat v. Missouri Bd. of Probation & Parole, 932 S.W.2d 835, 838 (Mo.App. W.D.1996).
Haulers contend their case is the exception because the trial court's 25 June judgment answered a question of law. Haulers' focus on the court's legal analysis in its 25 June judgment, however, ignores that the court denied the preliminary writ much earlier on 29 May, without answer from the County and in an order containing no merits ruling.[2] The law is clear that we cannot review the trial court's denial of Haulers' petition for a preliminary writ of mandamus absent such exceptional circumstances.[3]

Declaratory Judgment
That leaves the trial court's dismissal of Haulers' request for declaratory judgment. *340 Before we proceed, we must examine our jurisdiction over this count as well. See Chromalloy Am. Corp. v. Elyria Foundry Co., 955 S.W.2d 1, 3 (Mo. banc 1997) (a reviewing court has a duty to determine its jurisdiction sua sponte).
Where, as here, the trial court does not specify in its judgment whether the dismissal is with or without prejudice, we deem it without prejudice. Rule 67.03. Ordinarily, a dismissal without prejudice is not a final judgment and thus not appealable. Chromalloy Am. Corp., 955 S.W.2d at 3. Nevertheless, when the effect of the order is to dismiss the plaintiff's action and not merely the pleadingeffectively constituting an adjudication on the merits then the judgment entered is final and appealable. Mahoney v. Doerhoff Surgical Servs., Inc., 807 S.W.2d 503, 506 (Mo. banc 1991).
Here, the trial court framed the issue as "whether, with the purpose to create a new trash collection system, St. Louis County through its charter may enact ordinances which take precedence over a state statute with the same purpose." The court then interpreted section 260.247 in conjunction with article VI, section 18(c) of the Missouri Constitution, and concluded that the former did not apply to St. Louis County. This amounted to an adjudication on the merits, and thus the court's dismissal, albeit without prejudice, is appealable.

Standard of Review
The standard of review for a judgment of dismissal is de novo. Dodson v. City of Wentzville, 133 S.W.3d 528, 533 (Mo.App. E.D.2004). To sufficiently state a claim for declaratory judgment, the petition need only allege facts that invoke substantive legal principles which entitle the petitioner to relief. City of Creve Coeur v. Creve Coeur Fire Pro. Dist., 355 S.W.2d 857, 859 (Mo.1962). "[T]he question... is not whether the petition shows that the plaintiff is entitled to the declaratory relief he seeks in accordance with the theory he states, but rather it is whether under the averments of the petition he is entitled to a declaration of rights at all." Washington University v. Royal Crown Bottling Co. of St. Louis, 801 S.W.2d 458, 463 (Mo.App. E.D.1990).

Discussion

Procedure
We first take up the ground relied upon by the trial court: failure to state a claim. The trial court's sole question to consider was whether the petition alleges facts which entitle Haulers to a declaration of their rights. Haulers need not prove they will prevail under their interpretation of the statutory scheme, or even that their interpretation is correct; they simply must show they are entitled to an interpretation at all. Haulers made this showing, which is not only clear from their petition, but also implicit in the trial court's judgment in that the court went on to expound an interpretation of section 260.247.
Therein lies the trial court's error: "[I]t is not the function of the trial court on a motion to dismiss or of this court on appeal from a judgment of dismissal to make an analysis of the law under which the rights are claimed or to construe the statutes in question or to determine on the merits whether plaintiff is entitled to the declaratory relief he seeks in accordance with the theory he states." City of Creve Coeur v. Creve Coeur Fire Protection Dist., 355 S.W.2d 857, 859-60 (Mo.1962). "If under the facts pleaded a plaintiff is entitled to declaration of rights at all, the petition is sufficient for that purpose even though it advances a mistaken contention of law. A plaintiff's *341 standing to claim declaratory reliefand to assert a legally protectible interestis not impaired by the probability that ultimately he will not prevail." Sandy v. Schriro, 39 S.W.3d 853, 856 (Mo.App. W.D. 2001). In other words, by engaging in a determination of the merits, the trial court implicitly acknowledged that Haulers had adequately stated a claim. See id.
The trial court was free to make a more expansive determination, but doing so necessitated converting the motion to dismiss into one for summary judgment. In that case, the court should have notified the parties, giving them time to prepare and present relevant evidence; or it must have been clear the parties waived such notice and consented to the conversion. Rule 55.27(a); State ex rel. Missouri Highway & Transp. Comm'n v. London, 824 S.W.2d 55, 58 (Mo.App. E.D.1991). Neither occurred here, and neither party has at any time suggested that this should be viewed as anything other than a dismissal.[4] The trial court's statutory interpretation was procedurally inconsistent with a dismissal for failure to state a claim, and thus improper. See Sandy, 39 S.W.3d at 857.
But were we simply to remand to correct this procedural deficiency, such exercise would be futile given the trial court's resolution regarding the application of section 260.247. To avoid this inefficiency, courts of appeal may review the issue of law directly where the trial court's premature legal ruling effectively precludes the plaintiff from refiling the same cause of action; or in this case, effectively precludes any fresh look on remand. See Jones v. Jackson County Circuit Court, 162 S.W.3d 53, 58 (Mo.App. W.D.2005); State ex rel. Hazelwood Yellow Ribbon Committee v. Klos, 35 S.W.3d 457, 464 (Mo.App. E.D.2000). Therefore, we will review the trial court's decision on whether section 260.247 applies in order to guide the court's determination on remand.

Interpretation of Section 260.247
The trial court's exposition of the operative issue as whether a St. Louis County ordinance creating a new trash collection system can take precedence over a state statute "with the same purpose" bypasses a threshold question: whether the St. Louis County ordinance in question and section 260.247 actually have the same purpose, or in other words, whether they both purport to regulate the same activity.
The parties and the trial court find common ground in the notion that charter counties possess wide authority under Missouri Constitution Article VI, Section 18(c),[5] to regulate municipal functions as they see fiteven in contravention of state statutes concerning the same powers. See, e.g., Casper v. Hetlage, 359 S.W.2d 781 (Mo.1962). So if section 260.247 in fact regulates a "municipal function," serving in effect as a default regulation for political subdivisions which do not have home rule, the County is constitutionally free to exercise legislative power over that function; but if section 260.247 is "within the province of general legislation involving the public policy of the state as a whole," then the County is bound by it regardless of its charter status. See State ex rel. St. Louis *342 County v. Edwards, 589 S.W.2d 283, 286 (Mo.1979) (holding that the juvenile code's comprehensive control of juvenile facilities for the purpose of providing care, protection, and discipline of children in the juvenile facility could not be overridden by St. Louis County's exercise of control over juvenile facility personnel (citing Flower Valley Shopping Center v. St. Louis County, 528 S.W.2d 749, 754 (Mo. banc 1975); State ex rel. Spink v. Kemp, 365 Mo. 368, 283 S.W.2d 502, 514 (1955))).
To resolve this question, the trial court imposed a balancing test, stating that "[t]he question is whether state-wide or local concern is greater." This approach, however, which appears to allow even a statute containing a matter of state-wide public policy to be trumped if the local concern is deemed "greater," adds unneeded complexity to our Supreme Court's indications that finding a statute to be general and to involve state-wide public policy ends the inquiry. Edwards, 589 S.W.2d at 286.
Under the proper approach to statutory interpretation, we first look at the statute's plain language to discern the legislative intent. Elrod v. Treasurer of Mo. as Custodian of Second Injury Fund, 138 S.W.3d 714, 716 (Mo. banc 2004). Section 260.247 provides:
1. Any city or political subdivision which annexes an area or enters into or expands solid waste collection services into an area where the collection of solid waste is presently being provided by one or more private entities, for commercial or residential services, shall notify the private entity or entities of its intent to provide solid waste collection services in the area by certified mail.
2. A city or political subdivision shall not commence solid waste collection in such area for at least two years from the effective date of the annexation or at least two years from the effective date of the notice that the city or political subdivision intends to enter into the business of solid waste collection or to expand existing solid waste collection services into the area, unless the city or political subdivision contracts with the private entity or entities to continue such services for that period....
Section 260.247. The County characterizes this language as covering "the regulation and disposition of trash, garbage and other waste." And from that vantage point, the County contends that it is "impossible to deny" this is a municipal function. Inasmuch as we disagree with the County's characterization of the statute, we need not resolve the latter point concerning whether regulation of trash collection is a municipal function.[6]
The statute's plain language covers notice and entering the business of trash collectiona matter of undeniable state-wide public policyrather than operational aspects of trash collection, that once initiated, may indeed fall within the purview of a county's police power. As we said in Christian Disposal, Inc. v. Village of Eolia, "[t]he fundamental purpose of section 260.247 is to provide an entity engaged in waste collecting with sufficient notice to make necessary business adjustments prior to having its services terminated in a given area." 895 S.W.2d 632, *343 634 (Mo.App. E.D.1995). This has nothing to do with the process of an entity's collection of trash and everything to do with mitigating the effects of a government's takeover of trash collection on that entity's business. This general purpose reflects the state policy of protecting private entities engaged in trash collection, rather than a locally-centered purpose to provide a default regulation over the process of trash collection for entities without home rule charters.
Thus section 260.247 does not conflict with the County's trash collection ordinance, nor do the two have the same purpose as the trial court concluded. The County is authorized to enter the business of trash collection, and even to take it out of the hands of private collectors.[7] But enacting an ordinance which would allow the County to do so without following the notice requirement and waiting period in section 260.247 would bring it "out of harmony with the general laws of the states" and amount to "[an] attempt to change the policy of the state as declared for the people at large." State ex rel. Spink v. Kemp, 365 Mo. 368, 283 S.W.2d 502, 514 (1955). A charter county's exercise of power that produces this result is impermissible. The County here can both take over trash collection as it wishes while at the same time remaining in harmony with the public policy of the state. Accordingly, we find that the County does not have authority to legislate over the requirements of section 260.247.

Failure to Join Indispensable Parties
The County argues that we should nevertheless affirm the dismissal because Haulers failed to join indispensable parties. See Property Exchange & Sales, Inc. v. King, 822 S.W.2d 572, 573 (Mo.App. E.D.1992) (we may affirm the dismissal for any reason identified in the motion to dismiss, regardless of whether the trial court actually relied upon that ground). The County argues that Veolia was an indispensable party, and Haulers' failure to join Veolia in the litigation was grounds for dismissal. Although Rule 52.04 states that if the court determines a party to be indispensable to the litigation, yet that party cannot be joined, then the court must dismiss the lawsuit; the trial court made no findings on this issue, regarding either whether Veolia is indispensable or whether Veolia could not be joined. We are without adequate evidence to make such a determination, and we instruct the trial court to take up this issue on remand.

Conclusion
Because the trial court denied Haulers' petition for a preliminary writ of mandamus, without the exceptional circumstances of an answer by the County or a ruling on a question of law, we do not have jurisdiction to review it.
We do have jurisdiction to review the court's dismissal without prejudice of Haulers' request for declaratory judgment because the trial court determined questions of law in that dismissal. In fact, it was the trial court's interpretation of section 260.247an impermissible ruling on the merits without converting the motion to one for summary judgmentthat requires us to reverse and remand. Recognizing that simple remand would be futile given the trial court's conclusion, however, we correct the court's interpretation of section 260.247, holding that it is a general statute of state-wide public policy. Thus, St. Louis County may not exercise its constitutional *344 legislative authority to override section 260.247.
REVERSED AND REMANDED.
NANNETTE A. BAKER, C.J., and SHERRI B. SULLIVAN, J., concur.
NOTES
[1]  Neither the County's memorandum in support nor Haulers' memorandum in opposition are part of the record on appeal.
[2]  We also note that this order was not in Haulers' appendix, in violation of Rule 84.04(h)(1) (requiring appellants to include the judgment in question in their appendix).
[3]  In fact, Haulers received the available review by filing writ petitions both in this Court and in the Missouri Supreme Court.
[4]  Revealingly, counsel for the County stated at oral argument that she did not consider the judgment itself of great importance to our review.
[5]  That section states, in relevant part: "The [county] charter may provide for the vesting and exercise of legislative power pertaining to any and all services and functions of any municipality or political subdivision, except school districts, in the part of the county outside incorporated cities." Mo. Const. art. VI, § 18(c).
[6]  We do note the following problem in the trial court's analysis, however. The trial court cited Appelbaum v. St. Louis County, 451 S.W.2d 107 (Mo. 1970), for the proposition that "trash control is a municipal concern subject to local regulation," but that case turned on whether a city zoning ordinance can restrict the county's power to regulate the location of buildings (specifically, trash incinerators), and did not consider whether the county can be exempt from a state-wide regulation; nor whether trash collection, as opposed to zoning, is a municipal function.
[7]  This authorization comes both from Missouri Constitution article VI, section 18(c), and from the St. Louis County Charter, section 2.180.11.
