List returning null in Middle Tier

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

List returning null in Middle Tier

Post by wjstarck »

Hello-

This code works fine with a local db and server, but is returning null when run in Middle Tier :

Code: Select all

listAnesthVSData = AnesthVSDatas.CreateObjects(anestheticRecordNum);
This code is fetching data that populates an OD grid.

Here is that code:

Code: Select all

		public static List<AnesthVSData> CreateObjects(long anestheticRecordNum) {
			if(RemotingClient.MiddleTierRole == MiddleTierRole.ClientMT) {
				return Meth.GetObject<List<AnesthVSData>>(MethodBase.GetCurrentMethod(),anestheticRecordNum);
			}
			string dbName = FormAnesthesia.GetODDbName();
			string command="SELECT * FROM " + dbName + "." + "anesthvsdata WHERE AnestheticRecordNum = " + POut.Long(anestheticRecordNum) + " ORDER BY VSTimeStamp DESC";
			return Crud.AnesthVSDataCrud.SelectMany(command);
		}
It's similar to what's used on Employees.cs and Routings.cs so i can't figure out why no list is being returned?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: List returning null in Middle Tier

Post by wjstarck »

Version is 25.1.36.

Not sure if it matters, but the anesthetic record data and time populate a listBox, and the user can add/delete to this list and switch between records. I notice that the data on the form only partially load, and some tabs are completely greyed out, so somehow the primary key (anestheticRecordNum) is not being passed to the these other tabs and forms.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
jsalmon
Posts: 1606
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: List returning null in Middle Tier

Post by jsalmon »

The .SelectMany() method in the CRUD classes that Open Dental uses physically cannot return null and will return an empty list instead. What does your CRUD.SelectMany() method look like?
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: List returning null in Middle Tier

Post by wjstarck »

Code: Select all

		internal static List<AnesthVSData> SelectMany(string command){
			if(RemotingClient.MiddleTierRole == MiddleTierRole.ClientMT) {
				throw new ApplicationException("Not allowed to send sql directly.  Rewrite the calling class to not use this query:\r\n"+command);
			}
			DataTable table = DataCore.GetTable(command);
			List<AnesthVSData> list=TableToList(table);
			return list;
		}
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
jsalmon
Posts: 1606
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: List returning null in Middle Tier

Post by jsalmon »

wjstarck wrote: Mon Aug 11, 2025 9:46 am

Code: Select all

		internal static List<AnesthVSData> SelectMany(string command){
			if(RemotingClient.MiddleTierRole == MiddleTierRole.ClientMT) {
				throw new ApplicationException("Not allowed to send sql directly.  Rewrite the calling class to not use this query:\r\n"+command);
			}
			DataTable table = DataCore.GetTable(command);
			List<AnesthVSData> list=TableToList(table);
			return list;
		}
And if .TableToList() cannot return null then it isn't this code at fault.
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com
User avatar
jsalmon
Posts: 1606
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: List returning null in Middle Tier

Post by jsalmon »

Everything that you shared so far looks correct to me. Were you able to figure out why null was being returned instead of an empty list?
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com
Post Reply