So I am new to NPOCO and virtually have no experience with Oracle! But I am tasked with crating a method that writes some data to a table! here is my situation. I created my Model
[TableName("API_ANALYTICAL_DATA")]
[PrimaryKey("GID")]
public class ApiAnalyticalData
{
public ApiAnalyticalData() { }
[Ignore]
public string GID { get; set; }
[Column("RESOURCE_UID"), ColumnType(typeof(OracleNumber))]
public decimal ResourceID { get; set; }
[Column("REQUEST_TIME"), ColumnType(typeof(OracleDateTime))]
public string RequestDateTime { get; set; }
[Column("COMPLETION_TIME"), ColumnType(typeof(OracleDateTime))]
public string CompletionTime { get; set; }
[Column("STATUS_CODE"), ColumnType(typeof(OracleNumber))]
public decimal StatusCode { get; set; }
[Column("STATUS_MESSAGE"), ColumnType(typeof(OracleString))]
public string StatusMessage {get;set;}
[Column("REMOTE_ADDRESS"), ColumnType(typeof(OracleString))]
public string RemoteAddress { get; set; }
[Column("REQUEST_URL"), ColumnType(typeof(OracleString))]
public string RequestUrl { get; set; }
[Column("REQUEST_METHOD"), ColumnType(typeof(OracleString))]
public string RequestMethod { get; set; }
[Column("RESPONSE_HEADERS"), ColumnType(typeof(OracleString))]
public string ResponseHeaders { get; set; }
[Column("REQUEST_HEADERS"), ColumnType(typeof(OracleLob))]
public string RequestHeaders { get; set; }
[Column("REQUESTOR_UUPIC"), ColumnType(typeof(OracleString))]
public string RequstorID { get; set; }
[Column("IS_RESOURCE_UID_FK_VALID"), ColumnType(typeof(OracleString))]
public string IsResourceIdValid { get; set; }
[Column("ERR_MESSAGE"), ColumnType(typeof(OracleLob))]
public string ErrorMessage { get; set; }
}
I also have a data mapper setup
public class DataMappings : Mappings
{
public DataMappings()
{
For<ApiAnalyticalData>()
.TableName("API_ANALYTICAL_DATA")
.PrimaryKey("GID")
.Columns(d => {
d.Column(c => c.GID).Ignore();
d.Column(c => c.ResourceID).WithName("RESOURCE_UID").WithDbType(typeof(OracleNumber));
d.Column(c => c.RequestDateTime).WithName("REQUEST_TIME").WithDbType(typeof(OracleDateTime));
d.Column(c => c.CompletionTime).WithName("COMPLETION_TIME").WithDbType(typeof(OracleDateTime));
d.Column(c => c.StatusCode).WithName("STATUS_CODE").WithDbType(typeof(OracleNumber));
d.Column(c => c.StatusMessage).WithName("STATUS_MESSAGE").WithDbType(typeof(OracleString));
d.Column(c => c.RemoteAddress).WithName("REMOTE_ADDRESS").WithDbType(typeof(OracleString));
d.Column(c => c.RequestUrl).WithName("REQUEST_URL").WithDbType(typeof(OracleString));
d.Column(c => c.RequestMethod).WithName("REQUEST_METHOD").WithDbType(typeof(OracleString));
d.Column(c => c.ResponseHeaders).WithName("RESPONSE_HEADERS").WithDbType(typeof(OracleString));
d.Column(c => c.RequestHeaders).WithName("REQUEST_HEADERS").WithDbType(typeof(OracleLob));
d.Column(c => c.RequstorID).WithName("REQUESTOR_UUPIC").WithDbType(typeof(OracleString));
d.Column(c => c.IsResourceIdValid).WithName("IS_RESOURCE_UID_FK_VALID").WithDbType(typeof(OracleString));
d.Column(c => c.ErrorMessage).WithName("ERR_MESSAGE").WithDbType(typeof(OracleLob));
});
}
}
And my DB factory
public static class DBFactory
{
public static DatabaseFactory Databasefactory { get; set; }
public static void Setup(string DBConnnectionString)
{
var dbConfig = FluentMappingConfiguration.Configure(new DataMappings());
Databasefactory = DatabaseFactory.Config( x => {
x.UsingDatabase( () => new Database(DBConnnectionString));
x.WithFluentConfig(dbConfig);
x.WithMapper( new Mapper());
});
}
}
So I call the this setup method on application start up
protected void Application_Start()
{
DBFactory.Setup("uptmstora");
}
And this is the method that will insert the data
public T PostData<T>(T model)
{
dbContext.Insert<T>(model);
return model;
}
and it is called like so
var DataModel = JsonConvert.DeserializeObject<ApiAnalyticalData>(json);
PostData(DataModel)
All this works fine until I get the dbContext.Insert(model); I get an exception, Oracal.DataAccess.Client.OracleException with exception message "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY"
I have been over and over the data, and everything looks good, not sure what else to do with it at this point. So I guess the question is, does anyone have any kind of experience with NPOCO and saving data into oracle, I mean I tried with and with out the Mapper and I get the same error. Here is a sample of the JSON that gets de-Serialized into my model :
{
"ResourceID": 54469,
"RequestDateTime": "31-AUG-15",
"CompletionTime": "1-SEP-15",
"StatusCode": 200,
"ErrorMessage": "",
"StatusMessage": "Success",
"RemoteAddress": "192.1.1.2",
"RequestUrl": "http://www.somewebservice.com/",
"RequestMethod": "SomeMethod",
"ResponseHeaders": "Success 200",
"RequestHeaders": "GET",
"RequstorID": "1000",
"IsResourceIdValid": "Y"
}
EDIT: Here is the table as requested