forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # build-common/common.xml
- Loading branch information
Showing
8 changed files
with
159 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...rnate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/DoubleStringUserType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Data; | ||
using NHibernate.SqlTypes; | ||
using NHibernate.UserTypes; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.EntityWithUserTypeCanHaveLinqGenerators | ||
{ | ||
public class DoubleStringUserType : IUserType | ||
{ | ||
public SqlType[] SqlTypes | ||
{ | ||
get { return new[] { SqlTypeFactory.GetString(20) }; } | ||
} | ||
|
||
public System.Type ReturnedType | ||
{ | ||
get { return typeof(string); } | ||
} | ||
|
||
public bool IsMutable | ||
{ | ||
get { return false; } | ||
} | ||
|
||
public int GetHashCode(object x) | ||
{ | ||
if (x == null) | ||
{ | ||
return 0; | ||
} | ||
return x.GetHashCode(); | ||
} | ||
|
||
public object NullSafeGet(IDataReader rs, string[] names, object owner) | ||
{ | ||
object obj = NHibernateUtil.String.NullSafeGet(rs, names[0]); | ||
if (obj == null) | ||
{ | ||
return null; | ||
} | ||
return Convert.ToDouble((string)obj); | ||
} | ||
|
||
public void NullSafeSet(IDbCommand cmd, object value, int index) | ||
{ | ||
if (value == null) | ||
{ | ||
((IDataParameter)cmd.Parameters[index]).Value = DBNull.Value; | ||
} | ||
else | ||
{ | ||
var doubleValue = (double)value; | ||
((IDataParameter)cmd.Parameters[index]).Value = doubleValue.ToString(); | ||
} | ||
} | ||
|
||
public object DeepCopy(object value) | ||
{ | ||
return value; | ||
} | ||
|
||
public object Replace(object original, object target, object owner) | ||
{ | ||
return original; | ||
} | ||
|
||
public object Assemble(object cached, object owner) | ||
{ | ||
return cached; | ||
} | ||
|
||
public object Disassemble(object value) | ||
{ | ||
return value; | ||
} | ||
|
||
bool IUserType.Equals(object x, object y) | ||
{ | ||
return object.Equals(x, y); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters