public static YellowstonePathology.Business.Client.Model.ClientGroupClientCollection GetClientGroupClientCollectionByClientGroupId(int clientGroupId) { YellowstonePathology.Business.Client.Model.ClientGroupClientCollection result = new Client.Model.ClientGroupClientCollection(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from tblClientGroupClient where ClientGroupId = @ClientGroupId"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@ClientGroupId", SqlDbType.Int).Value = clientGroupId; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { YellowstonePathology.Business.Client.Model.ClientGroupClient clientGroupClient = new Client.Model.ClientGroupClient(); YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(clientGroupClient, dr); sqlDataReaderPropertyWriter.WriteProperties(); result.Add(clientGroupClient); } } } return result; }
public static YellowstonePathology.Business.Client.Model.ClientGroupClientCollection GetClientGroupClientCollectionByClientGroupId(List<int> clientGroupIds) { string inClause = YellowstonePathology.Business.Helper.IdListHelper.ToIdString(clientGroupIds); YellowstonePathology.Business.Client.Model.ClientGroupClientCollection result = new Client.Model.ClientGroupClientCollection(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select * from tblClientGroupClient where ClientGroupId in (" + inClause + ")"; cmd.CommandType = CommandType.Text; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { YellowstonePathology.Business.Client.Model.ClientGroupClient clientGroupClient = new Client.Model.ClientGroupClient(); YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(clientGroupClient, dr); sqlDataReaderPropertyWriter.WriteProperties(); result.Add(clientGroupClient); } } } return result; }