The district attorney shall render legal services to the county without fee and may render legal services to school districts and to other local public entities as requested. The district attorney may charge a school district or other local public entity a fee, not to exceed the total cost to the county, for the legal services rendered.