INSERT查询在数据库中添加行,但删除最后一行(INSERT query adds row in database but removes last row)
调试我没有写的系统时,我遇到了一个速度缓冲。 每次提交INSERT查询时,在对表进行排序后,最后一行总是被删除(即在ABDEF表上插入C,结果为ABCDE)。 如果在最后一行完成INSERT(即在ABCDEF的表上插入G,结果为ABCDEG),它将替换最后一行。
任何想法,我应该尝试寻找? 在Eclipse上调试。
I have hit a speed bump in debugging a system I didn't write. Every time an INSERT query is committed, after using sorting the table, the last row is always deleted (i.e. inserting C on a table of A B D E F, results to A B C D E). If the INSERT is done on the last row (i.e. inserting G on a table of A B C D E F, results to A B C D E G), it replaces the last row.
Any idea where I should try looking into? Debugging on Eclipse.
原文:https://stackoverflow.com/questions/43448034
最满意答案
你有没有尝试过这样的事情?
list1 = From t In list1 Where Not list2.Any(l => t.column1 = l.column1 AndAlso t.column2 = l.column2)
我不确定它的效率如何,但我认为它应该适合你。
Have you tried something like this?
list1 = From t In list1 Where Not list2.Any(l => t.column1 = l.column1 AndAlso t.column2 = l.column2)
I am unsure how efficient it would be, but I think it should work for you.
相关问答
更多-
LINQ - 查找一个列表中不在另一个列表中的所有项目(LINQ - Find all items in one list that aren't in another list)[2023-07-21]
尝试使用.Except扩展方法(docs) : var result = list1.Except(list2); 将给你列表list1中不在列表2中的所有项目。 Try using .Except extension method (docs): var result = list1.Except(list2); will give you all items in list1 that are not in list2. -
您可以创建一组状态ID以加快搜索速度,因为哈希集上的Contains()操作是O(1),列表中的Contains是O(N): HashSet
ids = new HashSet (specialStateIds); List NonSpacialRollIds = Students.Where(s => !ids.Contains(s.StateId)) .Select(s => s.RoleIds) ... -
从排除列表为空时排除Linq查询的结果(Exclude results from Linq query excluding everything when exclude list is empty)[2022-09-02]
那么,我知道它为什么失败:这是这个条款: from e in exclude 这将是一个空集合,所以没有条目甚至可以打到where子句。 这是另一种方法: var final = from f in tweets let lower = f.Text.ToLowerInvariant() where !exclude.Any(e => lower.Contains(e.ToLowerInvariant()) select f; 虽然 ... -
使用LINQ,其中项列表包含组件列表中的任何组件(Use LINQ where list of items contains any component in a list of components)[2023-08-30]
它应该是相反的方式:首先是Any ,然后是Contains 。 您希望获得components列表中包含 任何组件的所有项目。 如果您想获取Item列表,也不要使用Select : var result = items.Where(i => i.Components.Any(c => components.Contains(c.Name))); It should be the other way around: first the Any and then the Contains. You would ... -
这是最终的工作解决方案,花了很多时间来实现它 var AllForms = db.ClinicForms.Where(d => d.ClinicId == clinicId); var SignedForms = AllForms.Where(d => d.SignedForm.FormSigned == d.Id && d.SignedForm.PatientId == patientId); var res = AllForms.E ...
-
使用包含索引的Select的重载: var highIndexes = list.Select((value, index) => new { value, index }) .Where(z => z.value > 10) .Select(z => z.index); 步骤依次为: 将值序列投影到一系列值/索引对中 筛选以仅包含值大于10的对 将结果投影到一系列索引 Use the overload of Sele ...
-
你有没有尝试过这样的事情? list1 = From t In list1 Where Not list2.Any(l => t.column1 = l.column1 AndAlso t.column2 = l.column2) 我不确定它的效率如何,但我认为它应该适合你。 Have you tried something like this? list1 = From t In list1 Where Not list2.Any(l => t.column1 = l.column1 AndAlso t ...
-
Linq列表比较和排除(Linq List comparing and exclusion)[2022-08-17]
cups.Where(c => !bottles.Any(b => c.DrinkID == b.DrinkID) ) cups.Where(c => !bottles.Any(b => c.DrinkID == b.DrinkID) ) -
如果我没错的话, IEnumerable
mapCompanies = await db.mapCompanies.Where(mc => mc.userName.Equals(userName)).ToListAsync(); var mapLocations = mapCompanies.SelectMany(mapCompany => mapCompany.mapLocations) ... -
看看这是否有效: var results = myDataClass.LinksTabke.OrderBy(myURL => myURL.url_Description) .Where( myURL => myURL.PageID.Equals(QueryStringID) && ...