
[英]Is there a way to Remove entites from database by Id in a single line without iterating each?
我有一个字符串List<string>我从下面的方法var sentNotifications = Smtp.ProcessItems(queue, SmtpConfiguration); 我现在可以这样做: 但我不喜欢那样。 我能以某种方式检索组中的所有实体吗? 并同时删除它们? ...
[英]Is there a way to Remove entites from database by Id in a single line without iterating each?
我有一个字符串List<string>我从下面的方法var sentNotifications = Smtp.ProcessItems(queue, SmtpConfiguration); 我现在可以这样做: 但我不喜欢那样。 我能以某种方式检索组中的所有实体吗? 并同时删除它们? ...
[英]Sort list of objects based on the order of elements in an array
我在 SO & Google 上进行了高低搜索,但找不到类似的问题/答案。 所以我有一个 objectclass Animal { int Id; string Name; string Country; string Notes; } 这是输入var allAnimal ...
[英]Implementation of IEnumerable and IEnumerator in custom object, return the same data when called multiple times by LINQ with a different predicate
我希望能够在自定义 object 上使用 LINQ 查询,它不使用典型的 collections 但仍然以顺序方式存储数据。 XTable是包含 XRow 集合的XRows类型,我有以下实现IEnumerable和IEnumerator的代码。public class EnumerableXTab ...
[英]How to transpose data in Linq?
我从 Postgresql 表中获取以下数据,需要对每个月的 ListDate 字段求和并转置。 我试过这个链接Transpose a datatable using linq query,但实现它的方法不可行或不正确。 列表日期毫米 FC 高级管理系统 KS 2023-01-01 12 1 ...
[英]WinUI 3 CommunityToolkit Datagrid displaying data from two models while using CommunityToolkit.Mvvm
我的数据访问层中有两个模型:Table1 和 Table2。 我想使用 CommunityToolkit 中的 WinUI 3 DataGrid 来显示每个表中的两列:Table1.ColumnA、Table1.ColumnB、Table2.ColumnC、Table2.ColumnD 我的想法是在 ...
[英]Set value to a field in LINQ with logical expression
我正在为老师制作一个程序来控制学生的练习课。 如果字段有任何内容,我需要设置“有报告”之类的值,如果字段为 null 或为空,则需要设置“无报告”之类的值。 我有以下代码: C# 但它给了我错误: Microsoft.EntityFrameworkCore.Relational.dll 错误消息 ...
[英]EF Core 7 - The LINQ expression 'ProjectionBindingExpression: 14' could not be translated
几天前我们从 .net 5 迁移到 7,一切都很好,直到我今天不得不运行这个查询:var query = (from member in organization.Users let donor = member.Donor select new MembershipVM ...
[英]can i search in list with Dynamic LINQ parser
在代码页https://www.codeproject.com/Articles/355513/Invent-your-own-Dynamic-LINQ-parser首先阅读上面的页面我想在列表中搜索var item2 = new List<List<object>>() ...
[英]Is there a way I can paginate the included list in a linq query
希望你做得很好, 我试图用实体框架优化我的读取,我到达了 position,在那里我通过 id 从数据库中获取了一条记录,我想包含一个一对多的相关列表,但我不想得到列表的所有数据,只是一些,所以我想对它进行分页。 只要数据在IQueryable state 中,我就想执行此过程,我不想在 memor ...
[英]align a list by date in ascending order using OrderBy
我有这个查询获取一些有注册请求的项目,我创建了一个 class 来存储项目和字符串中的请求数据,我需要按创建日期从最新到最旧对它们进行排序。 尝试使用 OrderBy 但它不起作用,发生了什么事? ...
[英]how to combine and convert two integer columns to datetime lambda c#
我在 sql 数据库中有 2 个 int 列,一个用于月份,一个用于年份 我想针对数据库查询这个 DateFrom 是 dateTime,DateTo 也是 DataTime 但是如果用户将 1/1/2021 发送到 1/1/2023 就会出现问题它只会在 2021 年 1 月、2022 年 1 ...
[英]Ef Core 7, how to get one latest message per customer with take and skip
我有以下客户和客户消息 model。我想获得最新消息的前 n 个客户,并且只包含每个客户的最新消息。 我在 Postgres 上使用 EfCore 7,我的数据库有大约一百万客户,每个客户可能有大约 10 到 100 条消息。public class Customer { public l ...
[英]Linq Join multi key one side of key is null
尝试连接两个表,其中一侧的部分键可以为空。 获取“无法从用法中推断出类型 arguments”,我认为这与密钥中的不匹配类型有关。 试图在 TableA 中转换键的类型 或者 试图合并 TableB 中的键,幻数 0 不是很好,但在这种情况下会起作用。 试过 GetValueOrDefault 我 ...
[英]get elemets from elemets in complex XML using LINQ
我有一个复杂的 xml,我需要获取所有元素<sdnEntry>在标签<sdnType> > 中包含值“Individual” 这是我的 XML: 到目前为止我已经尝试过了,但它不起作用: 我究竟做错了什么? 感谢您的帮助。 ...
[英]Apply inner global filters in EF Core
我对关系中的全局过滤器有疑问。 只有当我已经获取了数据库的寄存器时,全局过滤器才适用。 我有两个班级: 我有一个全局过滤器,只获取活跃的公司: modelBuilder.Entity<Company>().HasQueryFilter(filter => filter.Active ...
[英]How can I add an List with different data after loop beside existing list?
所以基本上我有 2 个不同的列表 输出列表在循环中填充,循环结束后它将在result列表中添加outputs列表。 这样在循环结束后输出将具有不同的值。 例如,在第一个循环结束后, output列表的数据如下: 等等这样result列表现在就会有这三个示例数据。 现在循环将再次命中并加载不同的数据 ...
[英]Querying multiple data using System.Linq
我是 .Net Framework 的新手,不是任何编程语言的专家。 我只是在学习新事物。 我想从我的数据库中获取 ID 为 2、6 和 9 的对象列表以及 ID 大于 20 的所有对象。这是我的代码。int [] toRemove= { 2, 6, 9 }; var contributions = ...
[英]SQL join query to LINQ using groupby and order by clause
我正在尝试将此连接查询复制到 linq..但我不明白在哪里添加 group by 和 order by 语句.. ...
[英]Convert this SQL query to LINQ?
在 Microsoft SQL 服务器中使用 SQL 查询,我能够得到我想要的结果。 现在我正尝试通过 LINQ 在我的项目中使用此查询。 我的 SQL 查询是 到目前为止,我的 LINQ 查询是 我知道 BlastRecord_Id 设置为 1599,它是 LINQ 中的一个变量。这是故意的。 ...
[英]Convert SQL query to linq method syntax. Multiple group by and week of year required
我有这个 tSQL 查询,它返回我需要从数据中看到的内容。 我需要 linq 方法语法中的这个尽可能接近我一直在尝试这两种尝试,但我没有取得任何进展。 我还意识到现在 ISOweek 方法在 EF 中不起作用,因为它不能转换为 sql。所以我需要找到另一种方法来匹配一年中的星期。 我需要一些关于如何 ...