请考虑以下实体
public class What {
public int Id { get; set; }
public string Name { get; set; }
public ICollection<Track> Tracks { get; set; }
public int? LastTrackId { get; set; }]
public Track LastTrack { get; set; }
}
public class Track {
public Track(string what, DateTime dt, TrackThatGeoposition pos) {
What = new What { Name = what, LastTrack = this };
}
public int Id { get; set; }
public int WhatId { get; set; } …Run Code Online (Sandbox Code Playgroud) 我正在尝试阅读pdf版本> = 1.5的外部参照表.
xref表是一个对象:
58 0 obj <</DecodeParms<</Columns 4/Predictor 12>>/Filter/FlateDecode/ID[<CB05990F613E2FCB6120F059A2BCA25B><E2ED9D17A60FB145B03010B70517FC30>]/Index[38 39]/Info 37 0 R/Length 96/Prev 67529/Root 39 0 R/Size 77/Type/XRef/W[1 2 1]>>stream hÞbbd``b`:$AD`Ì ‰Õ Vˆ8âXAÄ×HÈ$€t¨ – ÁwHp·‚ŒZ$ìÄb!&F† .#5‰ÿŒ>(more here but can't paste) endstream endobj
如你看到的
但是:
解压缩的流长195个字节(39*5 = 195).所以条目的长度是4或5.
这是第一个膨胀的字节
02 01 00 10 00 02 00 02 cd 00 …
在我们的系统中,我们在 EF 核心中使用 QueryFilters 时遇到了性能问题。问题在于 EF 核心过滤器在 LEFT JOIN 内部进行过滤,而不是在其外部进行过滤。
生成的 SQL 看起来像这样:
SELECT [pom].[Id],
[pom].[DeleteDate],
[pom].[UpdateDate],
[pom].[Version],
[t].[Id],
[t].[MandatorId],
[t].[NetPriceAmount],
[t].[NetPriceCurrencyIso4217Code]
FROM [externaldata].[PurchaseOfferMetadata] AS [pom]
LEFT JOIN (
SELECT [po].[Id],
[po].[MandatorId],
[po].[NetPriceAmount],
[po].[NetPriceCurrencyIso4217Code]
FROM [externaldata].[PurchaseOffer] AS [po]
WHERE [po].[MandatorId] = 1
) AS [t] ON [pom].[Id] = [t].[Id]
WHERE [pom].[Id] IN
(CAST(3094411 AS bigint),
CAST(4757070 AS bigint),
CAST(4757112 AS bigint),
CAST(5571232 AS bigint))
Run Code Online (Sandbox Code Playgroud)
有问题的部分是WHERE [po].[MandatorId] = 1. 如果这是在第二个WHERE语句中,则查询运行得更快。
数据库模型配置如下:
modelBuilder.Entity<PurchaseOffer>()
.HasQueryFilter(po => po.MandatorId == 1) …Run Code Online (Sandbox Code Playgroud) 这是我的验证码:
string xsdPath = "base.xsd";
XDocument doc = XDocument.Load(xmlPath);
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add("http://some.domain.org", xsdPath);
schemas.Compile();
bool isValid = true;
doc.Validate(schemas, (o, e) => {
res.AddMessage(MessageSeverities.Error, $"{e.Severity}:{e.Message}");
isValid = false;
});
if ( isValid ) {
res.AddMessage(
MessageSeverities.Notice,
$"{formFile.FileName} is valid!");
}
Run Code Online (Sandbox Code Playgroud)
在桌面应用程序(.net 4.6)中使用时,此代码可以正常运行
在.net core asp 2.1控制器中使用时,该代码失败,并引发以下异常schemas.Compile();:
XmlSchemaException:未声明类型' http://some.domain.org:tAccountingItemTypes '。
似乎相关的架构文件未加载到asp核心应用程序中。如何强制加载相关架构?
模式是:
基本文件
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema
targetNamespace="http://some.domain.org"
xmlns="http://some.domain.org"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:include id="enums" schemaLocation="enums.xsd"/>
<xs:complexType name="tAccountingLines">
<xs:sequence>
<xs:element name="AccountingLine" type ="tAccountingLine"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tAccountingLine"> …Run Code Online (Sandbox Code Playgroud) 我将Linq与实体框架一起使用.
GetSet1<T>().Union(GetSet2<T>())
Run Code Online (Sandbox Code Playgroud)
GetSetX返回IQueryable.
生成的SQL是UNION ALL.但我知道UNION是实现目标的好方法.实际上我的解决方法是:
GetSet1<T>().Union(GetSet2<T>()).Distinct()
Run Code Online (Sandbox Code Playgroud)
在这种情况下生成的sql就像:
select distinct Field...
from (
select distinct Field...
union all
select distinct Field...
) unionall
Run Code Online (Sandbox Code Playgroud)
我知道(因为这是被认为的方式)
select Field...
union
select Field...
Run Code Online (Sandbox Code Playgroud)
是最好的查询.那么有没有办法(我可以(实际上找到)让EntityFramework使用UNION而不是UNION ALL?
==========
1:添加<T>更多精度
我正在使用Entity Framework 6开发Web API。我必须执行一个复杂的SQL查询,该查询从多个表中获取数据,如代码所示。我已经尝试过,但是出现以下错误:
数据读取器具有多个字段。多个字段对于EDM原语或枚举类型无效。
该查询在SSMS查询分析器中成功返回了数据。
[HttpGet]
public IHttpActionResult getJobNo(string cmpCode, string branchCode)
{
string query = string.Format(
@"select
M.S1, M.S2, C.S2 As S30, M.S3, SC.S2 As S31, M.D1, M.S5,
JT.S2 As S32, M.S6, TM.S2 As S33, M.S10
from
MERTRM M, CMF C, CMFS SC, PMCD JT, PMCD TM
where
M.S100 = 'JOB' and M.S102 = '{0}' and
M.S108 = '{1}' and
M.S101 not in('U', 'C', 'F') and
M.S2 = C.S1 and C.S102 = '{0}' and
C.S100 = 'CC' and …Run Code Online (Sandbox Code Playgroud) 考虑以下代码:
var SomeObject = function (id) {
this.id = id;
};
SomeObject.prototype.Handler = function() { alert(this.id);};
var o = new SomeObject("bla");
$('#someDivId').on('shown.bs.modal', o.Handler);
Run Code Online (Sandbox Code Playgroud)
我期待一个弹出窗口说"bla",但我得到一个弹出窗口"someDivId".
有没有办法将实例方法用作事件处理程序?
我在JavaScript中将Class方法读作事件处理程序?并使用对象的方法作为事件处理程序,如何删除它?但我无法将它们转录到我的案子中.
以下代码块 await loader.Completion;
我只是不知道为什么?
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
namespace tests {
class Program {
static async Task Main(string[] args) {
Planner pl = new Planner();
Console.WriteLine(await pl.Count());
}
}
public class Planner {
private TransformBlock<int, string[]> loader;
private int _im = 0;
public Planner(int im = 5) {
_im = im;
loader =
new TransformBlock<int, string[]>(
async i => {
Console.WriteLine(i);
await Task.Delay(1000);
return new string[] { i.ToString() };
}
);
}
public async Task<long> Count() …Run Code Online (Sandbox Code Playgroud) c# ×3
.net-core ×2
.net ×1
dbcontext ×1
ef-core-2.0 ×1
ef-core-2.1 ×1
javascript ×1
linq ×1
pdf ×1
sql ×1
sql-server ×1
tpl-dataflow ×1
xml ×1