
555 N.W.2d 915 (1996)
SEPTRAN, INC., an Indiana corporation, Appellant,
v.
INDEPENDENT SCHOOL DISTRICT NO. 271, BLOOMINGTON, MINNESOTA, a Minnesota public corporation, Respondent.
No. C9-96-1114.
Court of Appeals of Minnesota.
December 3, 1996.
*917 Scott P. Drawe, Stich, Angell, Kreidler, Brownson & Ballou, P.A., Minneapolis, for Appellant.
Kingsley D. Holman, Holman Law Offices, Bloomington, for Respondent.
Considered and decided by HUSPENI, P.J., and PARKER and FORSBERG, JJ.

OPINION
THOMAS G. FORSBERG, Judge.[*]
Appellant challenges the district court's grant of summary judgment for respondent on appellant's breach of contract claims. Appellant argues that the parties' contract was not invalidated by appellant's failure to provide a performance bond, respondent waived the defense of invalidity, the contract should be enforced based on appellant's substantial performance under the contract, and respondent's failure to move for summary judgment on appellant's claim that respondent improperly withheld payment under the contract precluded summary judgment on that claim. Respondent challenges the district court's grant of summary judgment for appellant on respondent's claim for equitable relief. We affirm.

FACTS
In 1991, appellant Septran, Inc. (Septran) and respondent Independent School District Number 271, Bloomington, Minnesota (the district), entered into a busing services contract for the 1991-92 and 1992-93 school years, with an option in the district to renew the contract for the 1993-94 and 1994-95 school years. Under the contract, Septran *918 provided bus services for the district, and the district compensated Septran based on the number of buses used, the number of miles driven, and numerous other factors. The contract required Septran to provide a fleet of buses only half of which were older than six years, to maintain a number of specially equipped buses (SEBs) for use by the district, and to purchase a performance bond (bond). The contract permitted the district to deduct $25 each time that Septran violated a term of the contract. The district paid Septran approximately $3,000,000 for Septran's services in each of the years covered by the contract.
During the 1991-92 school year, the district did not use all of the SEBs which the contract required Septran to maintain for district use. During the next three school years covered by the contract, Septran repeatedly violated the bus age provisions of the contract and failed to purchase the required bond. The district withheld partial payment for Septran's violation of the bus age provisions. From October 1993 to July 1995, the district withheld $108,900, or $25 multiplied by the number of buses in violation of the bus age provisions and the number of days that appellant did not comply with the bus age provisions. In 1994, the district exercised its option to renew the contract before it knew that Septran had not purchased the required bond for the 1992-93 and 1993-94 school years.
On February 7, 1994, Septran sued the district for breach of contract, alleging that the district improperly withheld partial payment and failed to use the number of buses required under the contract. The district counterclaimed for breach of contract, alleging that Septran failed to provide a performance bond as required by law, and seeking an order declaring that the district properly withheld partial payment under the contract and granting restitution of the value of the premiums not paid by Septran.
Septran moved for summary judgment on the district's claims. The district moved for summary judgment on its breach of contract claim and on Septran's claim that the district failed to use the required number of buses. The district court found the contract invalid, granted Septran's motion for summary judgment on both of the district's claims, granted the district's motion for summary judgment on Septran's claim that the district failed to use the required number of buses, and sua sponte granted summary judgment against Septran on its claim that the district improperly withheld partial payment under the contract. Appellant seeks review of the summary judgments entered against it, while respondent appeals only the denial of its request for equitable relief.

ISSUES
1. Did the district court err in finding the contract void?
2. Did the district court err in dismissing the parties' claims on the contract?
3. Did the district court err in denying the district recovery on its restitution claim?

ANALYSIS
On appeal from summary judgment, the reviewing court must ask whether any genuine issues of material fact exist and whether the lower court erred in its application of the law. State by Cooper v. French, 460 N.W.2d 2, 4 (Minn.1990). Where the material facts are not in dispute, a reviewing court need not defer to the trial court's application of the law. Hubred v. Control Data Corp., 442 N.W.2d 308, 310 (Minn.1989). Only a clear abuse of discretion in a decision to grant or deny equitable relief will result in reversal. Nadeau v. County of Ramsey, 277 N.W.2d 520, 524 (Minn.1979).
1. Appellant argues that the district court erred in declaring the contract invalid. Appellant contends that Minn.Stat. § 123.37, subd. 1b (1990), alone governs validity of the contract, and that failure to provide a bond does not invalidate a contract under subdivision 1b. Subdivision 1b provides in relevant part:
Notwithstanding the provisions of subdivision 1 [of section 123.37] or section 574.26, a performance bond shall be required of a contractor on a contract for the transportation of school children only when and in *919 the amount deemed necessary by and at the discretion of the school board.
Id. Appellant argues that because subdivision 1b does not include a provision invalidating contracts for which the contractor fails to provide a bond, appellant's failure to provide a bond did not invalidate the contract. We disagree.
Under Minnesota law,
a contract with the state or with any municipal corporation or other public board or body thereof, for the doing of any public work, is not valid unless the contractor shall give bond to the state or other body contracted with * * *.
Minn.Stat. § 574.26 (1990). Subdivision 1 of section 123.37 contains bond requirement language substantially similar to that contained in section 574.26. See Minn.Stat. § 123.37, subd. 1 (1990) (providing that a person to whom a contract with an independent school district is awarded "shall give a sufficient bond to the board for its faithful performance"). The district did not waive the bond requirement as it was authorized to do under subdivision 1b. Rather, the district required a performance bond and specified its amount. Appellant, however, failed to purchase the required bond for the last three school years under the contract. Because the district did not waive the bond requirement and appellant failed to provide the required bond, the contract did not satisfy section 574.26 or section 123.37.
Appellant's argument that subdivision 1b alone governs validity of the contract rests on the theory that subdivision 1b, where applicable, supersedes and operates to the exclusion of the subdivision 1 and section 574.26 provisions stating that failure to provide a required bond renders a contract void. The plain language in subdivision 1 refutes appellant's argument, because by its express terms, subdivision 1 applies to every contract subject to section 123.37, including contracts under subdivision 1b, not just those contracts within subdivision 1.
Moreover, well-established rules of statutory construction require this court to harmonize apparently conflicting provisions where possible. See, e.g., Minn.Stat. § 645.26, subd. 1 (1994) (requiring that two conflicting laws be construed so as to give effect to both); see also Minn.Stat. §§ 645.16, 645.17(2) (1994) (directing courts to give effect to all statutory provisions, where possible). Subdivision 1 and section 574.26 invalidate contracts for which a required bond is not provided. Subdivision 1b lets the school board decide whether or not to require a bond. Reading subdivision 1, section 574.26, and subdivision 1b as consistent with each other, we find that where, as here, the board requires a bond under subdivision 1b and the contractor fails to provide one, the contract is invalid under subdivision 1 and section 574.26.
Appellant further contends that respondent waived the defense of invalidity by not timely pleading it. Minn.R.Civ.P. 8.03 requires that parties submitting responsive pleadings assert, inter alia, "illegality * * * and any other matter constituting an avoidance or affirmative defense." Minn.R.Civ.P. 8.03. A reviewing court will generally not consider affirmative defenses not raised in trial court pleadings and not considered by the trial court. Minnesota-Iowa Television Co. v. Watonwan T.V. Improvement Ass'n, 294 N.W.2d 297, 305 (Minn.1980).
"Issues litigated by either express or implied consent are treated as if they had been raised in the pleadings." Roberge v. Cambridge Coop. Creamery Co., 243 Minn. 230, 234, 67 N.W.2d 400, 403 (1954); see also O'Reilly v. Allstate Ins. Co., 474 N.W.2d 221, 223 (Minn.App.1991) (affirming consideration of issue on motion for summary judgment even though not raised in responsive pleadings). Consent may be commonly implied where the parties fail to object to issues not raised by the pleadings. See Roberge, 243 Minn. at 234, 67 N.W.2d at 403 (finding consent where party failed to object to evidence outside of the issues raised in the pleadings). In this case, the court raised the invalidity issue at the motions hearing and gave the parties 18 days' notice to prepare and file the additional pleadings. Appellant did not object to the court raising the issue or requesting the additional briefs. As a result, appellant consented, and may not now *920 object, to the court's assessment of the validity of the contract.[1]
2. Appellant argues that even if failure to provide a bond rendered the contract invalid by statute, the court should not treat the contract as void and deny appellant's claims on the contract because appellant substantially performed on the contract and the purchase of a bond was merely an incidental element of the contract. Appellant relies on the case of Lew Bonn Co. v. Herman, 271 Minn. 105, 135 N.W.2d 222 (1965), in which the court faced the choice of completely denying one party payment under a contract due to illegality of the contract or requiring the other party to pay for some of the services received from the complaining party. Id. at 109, 135 N.W.2d at 225-26. The Lew Bonn court held that the violation was incidental where the case involved none of the evils the statute was intended to guard against. Id.
We decline to apply the Lew Bonn holding here, because the facts in Lew Bonn and the facts here are readily distinguishable. Here, respondent paid appellant a total of approximately $6,000,000 during the 1993-94 and 1994-95 school years. Appellant alleges that respondent owes an additional $108,900 under the contract for these two years. This court need not, therefore, choose between denying appellant any payment under the contract or finding the contract valid despite appellant's failure to provide the required bond. Further, in contrast with Lew Bonn, evidence of the evils the statute was intended to guard against exist here because, due to appellant's failure to buy the bond, respondent could not have made a claim on a bond as the legislature apparently intended under sections 574.26 and 123.37, subdivision 1.[2]
Appellant argues that the court erred in granting summary judgment for respondent on appellant's claim that respondent improperly withheld payment under the contract, because respondent did not move for summary judgment on that claim. "A district court may, sua sponte, grant summary judgment if, under the same circumstances, it would grant summary judgment on motion of a party." Estate of Riedel v. Life Care Retirement Communities, Inc., 505 N.W.2d 78, 81 (Minn.App.1993) (citing Del Hayes & Sons v. Mitchell, 304 Minn. 275, 280, 230 N.W.2d 588, 591-92 (1975)). A reviewing court will not reverse a lower court grant of summary judgment unless the objecting party can show prejudice from lack of notice, procedural irregularities, or from the lack of a meaningful opportunity to oppose summary judgment. Id., 505 N.W.2d at 81.
Here, the court sua sponte granted summary judgment against appellant on its claim that respondent improperly withheld payment due under the contract. Appellant presents no reason why, if respondent had moved for summary judgment under the same circumstances, the court would have denied respondent's motion. Moreover, neither party has alleged procedural irregularities. *921 The court gave the parties notice at the motions hearing that it would consider the issue of invalidity of the contract, and gave the parties 18 days to submit briefs on the issue. On this record, we do not find that the court erred in granting summary judgment on this claim.
3. Respondent contends that the district court erred in denying respondent's request for equitable relief. Respondent claims the right to restitution of $60,000 which appellant saved by not purchasing the required bonds during the last three years of the contract. The district court denied respondent's claim on the ground that respondent failed to establish that it suffered injury due to appellant's failure to purchase the bonds, or that an award of $60,000 would return respondent to its precontract position. The record supports the district court's findings on these issues. See Pelletier Corp. v. Charles M. Freidheim Co., 383 N.W.2d 318, 322 (Minn.App.1986), review denied (Minn. May 16, 1986) (affirming denial of equitable relief where both parties could have taken steps to avoid litigation). The district court did not abuse its discretion in denying respondent's request for equitable relief.

DECISION
The district court properly found the contract invalid for appellant's failure to provide the required performance bond. Given the contract's invalidity, the court properly granted summary judgment against both parties on their claims on the contract. Because respondent failed to show that it suffered injury due to appellant's failure to purchase the required performance bond, respondent was not entitled to equitable relief.
Affirmed.
NOTES
[*]  Retired judge of the Minnesota Court of Appeals, serving by appointment pursuant to Minn. Const. art. VI, § 10.
[1]  We note that even if appellant had not waived its right to object to a decision on the validity of the contract, the district court properly addressed this issue. A trial court may consider all issues raised in the pleadings. See Beutz v. A.O. Smith Harvestore Prods., Inc., 431 N.W.2d 528, 532 n. 3 (Minn.1988) (finding no abuse of discretion in consideration of rule 8.03 defense raised for first time in amended pleadings). Moreover, a trial court has discretion to allow amendment of the pleadings. Niccum v. Hydra Tool Corp., 438 N.W.2d 96, 98 (Minn.1989). Here, the court requested additional pleadings from the parties on the issue of the contract's validity, and the five-page, single-spaced briefs submitted by the parties on this issue served as amendments to the pleadings.
[2]  We find appellant's assertion that the bond provision was incidental to the contract fundamentally questionable. Appellant asserts, in essence, that since respondent did not make any claims on the bond, the bond was incidental to the contract. If appellant had failed to provide adequate bus services, however, then in the absence of a bond, respondent would have been unable to obtain replacement services without paying for them itself. As a result, the bond requirement is not an incidental element of the contract. The absence of a claim on the bond does not make provision of the bond incidental to the contract any more than a trapeze artist's completion of a routine without falling makes the provision of a safety net incidental to his performance. Because both respondent and the trapeze artist might need to rely on their "safety net," the bond and the safety net are essential, not incidental.
