我有一个Javascript/JQuery函数,应该在AJAX请求后打开一个引导模式.
这适用于使用Chrome的PC,但遗憾的是它无法在iPhone上运行(Chrome/Safari)
按钮:
<button type="button" id="GetEmployees" class="btn btn-primary" onclick="GetEmployees()">
<span class="glyphicon glyphicon-user"> </span>Toevoegen
</button>
Run Code Online (Sandbox Code Playgroud)
功能:
function GetEmployees() {
$.ajax({
type: 'post',
url: appPath + '/TimeRegistration/GetEmployees',
data: { },
success: function (response) {
if (response != null) {
alert("Load");
$("#dialog-project .modal-body").html(response);
$("#dialog-project").modal("show");
alert("open");
}
},
error: function (response) {
alert("Onbekende fout opgetreden")
}
});
}
Run Code Online (Sandbox Code Playgroud)
这是对话框本身:
<div id="dialog-project" class="modal fade" tabindex="-1" role="dialog" style="color: #333333;">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 id="dialog-title" class="modal-title">Aanmaken nieuwe tijdregel</h4> …
Run Code Online (Sandbox Code Playgroud) 错误信息很明确:
''FromSql' 操作的结果中不存在所需的列 'CustomerId'
但不知何故,我真的没想到有一个 CustomerId?
错误发生在这里:
contacts = db.Contacts.FromSql("SIP_API_MONDIA_Contacts_sel").ToList();
addresses = db.Addresses.FromSql("SIP_API_MONDIA_Address_sel").ToList();
Run Code Online (Sandbox Code Playgroud)
控制器:
public IList<Customer> GetAllCustomers()
{
//Initialize the objects
IList<Customer> customers = null;
IList<Contacts> contacts = null;
IList<Addresses> addresses = null;
//Fetch the data from stored procedures
customers = db.Customers.FromSql("SomeProcName").ToList();
contacts = db.Contacts.FromSql("SomeProcName").ToList();
addresses = db.Addresses.FromSql("SomeProcName").ToList();
//Loop through customers and add the contact and addresses when required
foreach(var item in customers)
{
item.Contacts = contacts.Where(x => x.Customer == item.Id).ToList();
item.Addresses = addresses.Where(x => x.Customer == item.Id).ToList();
}
return …
Run Code Online (Sandbox Code Playgroud) 认为我的startup.cs有问题,因为我没有从我那里得到任何值 <IOption> config
所以..我们有我们的appsettings.json
"Config": {
"ApplicationName": "some name",
"ConnectionString": "someconstring",
"Version": "1.0.0"
},
Run Code Online (Sandbox Code Playgroud)
在这里,我们有我们的模型
public class Config
{
public string ApplicationName { get; set; }
public string ConnectionString { get; set; }
public string Version { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
startup.cs
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public static IConfiguration Configuration { get; set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection …
Run Code Online (Sandbox Code Playgroud) 对 ASP.Net Core 来说很新,特别是对于 API。过去,我习惯于使用默认控制器创建简单的 api,例如:
[Produces("application/json")]
[Route("api/TestCust")]
public class TestCustController : Controller
{
// GET: api/TestCust
[HttpGet]
public IEnumerable<Customer> Get()
{
IEnumerable<Customer> customer = null;
....
return customer;
}
// GET: api/TestCust/5
[HttpGet("{id}", Name = "Get")]
public IEnumerable<Customer> Get(int id)
{
IEnumerable<Customer> customer = null;
return customer;
}
Run Code Online (Sandbox Code Playgroud)
现在我在制作 API 时遇到了新的挑战,但客户端已经由第三方制作。这意味着,我被迫按照他们的方式去做。
幸运的是,它有很好的文档记录,并且他们提供了将发送到我的 API 的请求示例。其中一个请求如下:/Customers?$filter=ID+eq+guid'1D225D75-A587-4AE4-BA9A-2224B2484EA5'
为了获得所有客户: /Customers?$orderby=Code&$skip=100
现在,我对 OData 完全陌生,我昨天才发现这些,并且我一直在关注有关它的一些教程。虽然,他们中的大多数都使用实体框架,而我将 Dapper 与存储过程结合使用。
教程如下:https : //damienbod.com/2018/10/12/odata-with-asp-net-core/,https : //dotnetthoughts.net/perform-crud-operations-using-odata-in-aspnet-核/
所以我一直在尝试使用 提出请求, [EnableQuery]
但这还没有奏效。我将链接底部的错误。
那么,我到底做了什么?好吧,我更改了Startup.cs
public …
Run Code Online (Sandbox Code Playgroud) 客户是第三方,所以我无权访问该来源。不过,我有一份解释良好的 PDF,其中包含客户使用的一些请求示例。例如,
/Customers?$filter=ID+eq+guid'1D225D75-A587-4AE4-BA9A-2224B2484EA5'
/Customers?$filter=Code+eq+12345
Run Code Online (Sandbox Code Playgroud)
这是我第一次使用 OData 和实体框架,目前遇到了过滤问题。
当我执行一个简单的 GET 请求而不进行过滤时,它会正确返回数据。但是,当我做类似的事情时
http://localhost:52973/odata/customers?$filter=Code+eq+12069
Run Code Online (Sandbox Code Playgroud)
它返回错误:
{"error":{"code":"","message":"The query specified in the URI is not valid. A binary operator with incompatible types was detected. Found operand types 'Edm.String' and 'Edm.Int32' for operator kind 'Equal'.","details":[],"innererror":{"message":"A binary operator with incompatible types was detected. Found operand types 'Edm.String' and 'Edm.Int32' for operator kind 'Equal'.","type":"Microsoft.OData.ODataException","stacktrace":" at Microsoft.OData.UriParser.BinaryOperatorBinder.PromoteOperandTypes(BinaryOperatorKind binaryOperatorKind, SingleValueNode& left, SingleValueNode& right, TypeFacetsPromotionRules facetsPromotionRules)\r\n at Microsoft.OData.UriParser.BinaryOperatorBinder.BindBinaryOperator(BinaryOperatorToken binaryOperatorToken)\r\n at Microsoft.OData.UriParser.MetadataBinder.Bind(QueryToken token)\r\n at Microsoft.OData.UriParser.FilterBinder.BindFilter(QueryToken filter)\r\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, ODataPathInfo …
Run Code Online (Sandbox Code Playgroud)