Page 1 of 1

List returning null in Middle Tier

Posted: Sun Aug 10, 2025 10:09 am
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?

Re: List returning null in Middle Tier

Posted: Mon Aug 11, 2025 7:19 am
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.

Re: List returning null in Middle Tier

Posted: Mon Aug 11, 2025 9:27 am
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?

Re: List returning null in Middle Tier

Posted: Mon Aug 11, 2025 9:46 am
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;
		}

Re: List returning null in Middle Tier

Posted: Mon Aug 11, 2025 10:08 am
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.

Re: List returning null in Middle Tier

Posted: Tue Aug 19, 2025 11:06 am
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?