I have a application that uses a Geometry variable but it breaks my app. Can someone explain why this would happen?
I am new to asp.net MVC 6.
public Geometry? MR_MITIGATION_LATITUDE_LONGITUDE { get; set; }
{ "data": "mR_MITIGATION_REPORTING_UNIT" },
{ "data": "lU_DISTRICTS_NAME" },
{ "data": "mR_MITIGATION_PROJECT_NAME" },
{ "data": "mR_LU_OWNERSHIP_NAME" },
{ "data": "lU_COUNTIES_COUNTY_NAME" },
{ "data": "mR_MITIGATION_COMPLETION_DATE" },
{ "data": "mR_MITIGATION_LATITUDE_LONGITUDE" }
Rajkiran SwainPosted May 10, 2023, 5:50 PM
It's difficult to determine the exact cause of the issue without more information about your application and how you are using the `Geometry` variable. However, one possibility is that the `Geometry` type is not supported by the version of .NET or ASP.NET MVC that you are using, or that there may be an issue with how the variable is being used or accessed in your code.
It's also possible that there may be an issue with the data being passed to the `Geometry` variable, such as invalid data or a data type mismatch, which could cause your application to break.
To troubleshoot the issue, you could try debugging your code and checking for any error messages or exceptions that may provide more information about the problem. You may also want to check the documentation for the `Geometry` type to ensure that you are using it correctly.
Additionally, you could try testing your application with a different variable type to see if the issue persists, or consult with a more experienced developer or a support forum for help with troubleshooting the issue.
Charles McClellanPosted May 10, 2023, 6:19 PM
Thank you for responding Rajkiran.
The other variables in my model all work fine but it is this one data type that is giving me a problem. This code was inherited from another developer.
-------------------------------------------------------------------------------------------------------------
Below is the entire model:
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using NetTopologySuite.Geometries;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MitigationReporting.Common.Models
{
public class CommonView
{
// public int MR_LU_TEAMS_PK { get; set; }
//public string MR_LU_TEAMS_NAME { get; set; } = null!;
//public string LuDistrictsPK { get; set; } = null!;
//public string LuDistrictsName { get; set; } = null!;
//public int LuCountiesPk { get; set; }
//public string LuCountiesCountyName { get; set; } = null!;
[Key]
public int MR_MITIGATION_PK { get; set; }
[NotMapped]
public int District { get; set; }
[NotMapped]
public int County { get; set; }
[NotMapped]
public string? Pro_Name { get; set; }
[NotMapped]
public int RepUnitTeam { get; set; }
[NotMapped]
public int RepUnitType { get; set; }
public string? LU_DISTRICTS_NAME { get; set; }
public char LU_DISTRICTS_NUM { get; set; }
[NotMapped]
public int MR_LU_FUEL_TYPE_PK { get; set; }
[NotMapped]
public string? MR_LU_FUEL_TYPE_NAME { get; set; }
[NotMapped]
public int MR_LU_TREATMENT_TYPE_PK { get; set; }
[NotMapped]
public string? MR_LU_TREATMENT_TYPE_NAME { get; set; }
[NotMapped]
public int MR_LU_PROJECT_TYPE_PK { get; set; }
[NotMapped]
public string? MR_LU_PROJECT_TYPE_NAME { get; set; }
//public int MR_MITIGATION_DISTRICT_FK { get; set; }
//public int MR_MITIGATION_COUNTY_FK { get; set; }
public string? MR_MITIGATION_REPORTING_UNIT { get; set; }
public string? MR_MITIGATION_REPORTING_UNIT_TYPE { get; set; }
public string? MR_MITIGATION_PROJECT_NAME { get; set; }
public string? MR_LU_OWNERSHIP_NAME { get; set; }
public string? LU_COUNTIES_COUNTY_NAME { get; set; }
public DateTime MR_MITIGATION_COMPLETION_DATE { get; set; }
//public Geometry? MR_MITIGATION_LATITUDE_LONGITUDE { get; set; }
// public List? TeamList { get; set; }
// public List? DistrictList { get; set; }
//public List? CountyList { get; set; }
}
}
-------------------------------------------------------------------------------------------------------------
Below is the script that is in the index view:
$(document).ready(function(){
$("#searchindextable").DataTable({
//dom: '<"top"i>rt<"bottom"flp><"clear">',
});
$("#btnSearch").click(function () {
$.ajax({
url: "@Url.Action("GetSearch","Home")",
method: "Post",
data: { RepUnitType: $("#RepUnitType option:selected").val(), ReportUnit: $("#ReportUnit option:selected").val(), District: $("#District option:selected").val(), County: $("#County option:selected").val(), Pro_Name: $("#projectname").val() },
//data: { District: $("#District option:selected").val(), County: $("#County option:selected").val(), Pro_Name: $("#projectname").val() },
dataType: 'json',
success : function(data)
{
if(data.success)
{
if ($.fn.DataTable.isDataTable("#searchindextable")){
$("#searchindextable").DataTable().clear().destroy();
}
//debugger;
$("#searchindextable").DataTable({
data: data.result,
columns:
[
{
"data": "mR_MITIGATION_PK",
"render": function (data, type, row, metta){
if (type == 'display'){
var url = "/Home/MitPKRecord?MitigationPk=" + row["mR_MITIGATION_PK"];
//var url = "/AddMitReport/AddMitReport?MitigationPk=" + row["mR_MITIGATION_PK"];
//var url = "/Home/MitPKRecord?mR_MITIGATION_PK=" + row["mR_MITIGATION_PK"];
data = '' + row["mR_MITIGATION_PK"] + ''
}
return data;
}
},
{ "data": "mR_MITIGATION_REPORTING_UNIT" },
{ "data": "lU_DISTRICTS_NAME" },
{ "data": "mR_MITIGATION_PROJECT_NAME" },
{ "data": "mR_LU_OWNERSHIP_NAME" },
{ "data": "lU_COUNTIES_COUNTY_NAME" },
{ "data": "mR_MITIGATION_COMPLETION_DATE" },
{ "data": "mR_MITIGATION_LATITUDE_LONGITUDE" }
]
});
}
},
error: function(){
console.log("error");
}
});
});
});
-------------------------------------------------------------------------------------------------------------
Below is in the Homecontroller Index section:
List mitHomeRecord = new List();
return View(mitHomeRecord);
-------------------------------------------------------------------------------------------------------------
I think the code may have been used from this example:
https://www.c-sharpcorner.com/article/using-datatables-grid-with-asp-net-mvc/