* Reworked Data Framework so that MSSQL works
* Introduced uint as field type * Removed what should be superfluous Guid handling * Introduced stub MySQLDataReader if we need to fix the Guid handling anyway0.6.0-stable
parent
0e789a9a01
commit
667ebc8ea2
|
@ -31,7 +31,7 @@ using System.IO;
|
|||
|
||||
namespace OpenSim.Framework.Data.Base
|
||||
{
|
||||
public class BaseDataReader
|
||||
public abstract class BaseDataReader
|
||||
{
|
||||
private readonly IDataReader m_source;
|
||||
|
||||
|
@ -112,17 +112,28 @@ namespace OpenSim.Framework.Data.Base
|
|||
return m_source.Read();
|
||||
}
|
||||
|
||||
public Guid GetGuid(string name)
|
||||
public virtual Guid GetGuid(string name)
|
||||
{
|
||||
string guidString = GetString(name);
|
||||
if (String.IsNullOrEmpty(guidString))
|
||||
{
|
||||
return Guid.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Guid(guidString);
|
||||
}
|
||||
return m_source.GetGuid(m_source.GetOrdinal(name));
|
||||
}
|
||||
|
||||
public UInt32 GetUInt32(string name )
|
||||
{
|
||||
return (UInt32)GetInt32(name);
|
||||
}
|
||||
|
||||
private Int32 GetInt32(string name)
|
||||
{
|
||||
int ordinal = m_source.GetOrdinal(name);
|
||||
int int32 = m_source.GetInt32(ordinal);
|
||||
return int32;
|
||||
}
|
||||
|
||||
public Int64 GetInt64(string name)
|
||||
{
|
||||
int ordinal = m_source.GetOrdinal( name );
|
||||
long int64 = m_source.GetInt64(ordinal);
|
||||
return int64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,10 @@ namespace OpenSim.Framework.Data.Base
|
|||
{
|
||||
value = reader.GetUShort(m_fieldName);
|
||||
}
|
||||
else if (ValueType == typeof(uint))
|
||||
{
|
||||
value = reader.GetUInt32(m_fieldName);
|
||||
}
|
||||
else if (ValueType == typeof(byte[]))
|
||||
{
|
||||
value = reader.GetBytes(m_fieldName);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlClient;
|
||||
using OpenSim.Framework.Data;
|
||||
|
@ -44,6 +45,18 @@ namespace OpenSim.Framework.Data.MSSQLMapper
|
|||
return connection;
|
||||
}
|
||||
|
||||
public override object ConvertToDbType(object value)
|
||||
{
|
||||
if( value is UInt32 )
|
||||
{
|
||||
UInt32 tmpVal = (UInt32) value;
|
||||
Int64 result = Convert.ToInt64(tmpVal);
|
||||
return result;
|
||||
}
|
||||
|
||||
return base.ConvertToDbType(value);
|
||||
}
|
||||
|
||||
public override string CreateParamName(string fieldName)
|
||||
{
|
||||
return "@" + fieldName;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using OpenSim.Framework.Data.Base;
|
||||
|
||||
namespace OpenSim.Framework.Data.MySQLMapper
|
||||
{
|
||||
public class MySQLDataReader : OpenSimDataReader
|
||||
{
|
||||
public MySQLDataReader(IDataReader source) : base(source)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,9 +25,11 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using MySql.Data.MySqlClient;
|
||||
using OpenSim.Framework.Data;
|
||||
using OpenSim.Framework.Data.Base;
|
||||
|
||||
namespace OpenSim.Framework.Data.MySQLMapper
|
||||
{
|
||||
|
@ -48,5 +50,10 @@ namespace OpenSim.Framework.Data.MySQLMapper
|
|||
{
|
||||
return "?" + fieldName;
|
||||
}
|
||||
|
||||
public override BaseDataReader CreateReader(IDataReader reader)
|
||||
{
|
||||
return new MySQLDataReader( reader );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,11 +26,8 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
|
||||
using OpenSim.Framework.Data.Base;
|
||||
|
||||
namespace OpenSim.Framework.Data
|
||||
|
|
Loading…
Reference in New Issue