Quelqu'un a-t-il implémenté ceci, ou sait-il s'il serait difficile d'implémenter ceci/avoir des pointeurs?Critères SpatialRestrictions.IsWithinDistance NHibernate.Spatial
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
// TODO: Implement
throw new NotImplementedException();
}
de NHibernate.Spatial.Criterion.SpatialRestrictions
je peux utiliser "où NHSP.Distance (PROPRIÉTÉ,: Point)" dans hql. Mais je veux combiner cette requête avec ma requête Criteria existante.
pour le moment je crée un polygone rugueux, et en utilisant
criteria.Add(SpatialRestrictions.Intersects("PROPERTY", myPolygon));
EDIT Vous avez un prototype par le constructeur sur la surcharge SpatialRelationCriterion, l'ajout de nouveaux SpatialRelation.Distance
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
return new SpatialRelationCriterion(propertyName, SpatialRelation.Distance, anotherGeometry, distance);
}
a ajouté un nouveau champ à SpatialRelationCriterion
private readonly double? distance;
public SpatialRelationCriterion(string propertyName, SpatialRelation relation, object anotherGeometry, double distance)
: this(propertyName, relation, anotherGeometry)
{
this.distance = distance;
}
Edité ToSqlString
object secondGeometry = Parameter.Placeholder;
if (!(this.anotherGeometry is IGeometry))
{
secondGeometry = columns2[i];
}
if (distance.HasValue)
{
builder.Add(spatialDialect.GetSpatialRelationString(columns1[i], this.relation, secondGeometry, distance.Value, true));
}
else
{
builder.Add(spatialDialect.GetSpatialRelationString(columns1[i], this.relation, secondGeometry, true));
}
surcharge ISpatialDialect.GetSpatialRelationString
mis en œuvre surcharge MsSql2008SpatialDialect
public SqlString GetSpatialRelationString(object geometry, SpatialRelation relation, object anotherGeometry, double distance, bool criterion)
{
var x = new SqlStringBuilder(8)
.AddObject(geometry)
.Add(".ST")
.Add(relation.ToString())
.Add("(")
.AddObject(anotherGeometry)
.Add(")");
if (criterion)
{
x.Add(" < ");
x.AddObject(distance.ToString());
}
return x.ToSqlString();
}
Je ne sais pas pourquoi AddParameter pas utilisé?
J'ai le même problème, et je n'ai trouvé aucun patch/correctif/quoi que ce soit jusqu'à présent. L'avez-vous résolu, ou êtes-vous allé avec la variante HQL? – Liedman
Pensez allé avec l'approche ci-dessus, et a dll recompilled au travail, mais était encore le code expérimental. – Ian
@Amresh n'êtes-vous pas satisfait de la solution proposée par OP? – Eranga