コード例 #1
0
        public static YellowstonePathology.Business.Facility.Model.HostCollection GetHostCollection()
        {
            YellowstonePathology.Business.Facility.Model.HostCollection result = new YellowstonePathology.Business.Facility.Model.HostCollection();

            YellowstonePathology.Business.Mongo.Server transferServer = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection collection = transferServer.Database.GetCollection <BsonDocument>("Host");
            MongoCursor     cursor     = collection.FindAllAs <BsonDocument>();

            foreach (BsonDocument bsonDocument in cursor)
            {
                YellowstonePathology.Business.Facility.Model.Host host = new YellowstonePathology.Business.Facility.Model.Host();
                YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, host);
                result.Add(host);
            }
            return(result);
        }
コード例 #2
0
        public static YellowstonePathology.Business.Facility.Model.HostCollection GetHostCollection()
        {
            #if MONGO
            return AccessionOrderGatewayMongo.GetHostCollection();
            #else
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select * from tblHost";
            cmd.CommandType = CommandType.Text;

            YellowstonePathology.Business.Facility.Model.HostCollection hostCollection = new YellowstonePathology.Business.Facility.Model.HostCollection();
            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.BaseData.SqlConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Facility.Model.Host host = new YellowstonePathology.Business.Facility.Model.Host();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(host, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        hostCollection.Add(host);
                    }
                }
            }
            return hostCollection;
            #endif
        }