.net

Entity Framework 6 - Attaching a graph of entities queried with AsNoTracking

我的未来我决定 提交于 2021-02-11 13:47:06
问题 I am retrieving a list of entities from a table FattureFornitori , and loading also a collection owned by them (Voci, plural form - Voce, singular form) and a reference from each Voce to a TipoCosto entity: var db = new DbGestPre(); db.Configuration.ProxyCreationEnabled = false; var s = db.FattureFornitori .Include(x => x.Voci) .Include(x => x.Voci.Select(y => y.TipoCosto)) .AsNoTracking().ToList(); Now, multiple Voci within a single FattureFornitori can reference the same TipoCosto . So,

Automapper: UseDestinationValue does not work for collections?

不羁的心 提交于 2021-02-11 13:40:57
问题 Let's assume there are classes: public class Foo { public List<Bar> Bars { get; set; } } public class Bar { public string Name { get; set; } public string Description { get; set; } } public class FooDto { public List<BarDto> Bars { get; set; } } public class BarDto { public string Name { get; set; } } public class MapperProfile : Profile { public MapperProfile() { CreateMap<FooDto, Foo>(); CreateMap<BarDto, Bar>() .ForMember(dest => dest.Description, opt => opt.UseDestinationValue()); } } If

Using ObservableCollection across UI and Non-UI threads

我是研究僧i 提交于 2021-02-11 13:38:57
问题 I am using the SortableObservableCollection described here. Now I'd like to manipulate it from a UI or a non-UI thread so I tried the solution described here: using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Runtime; using System.Windows.Data; public class SortableObservableCollection<T> : ObservableCollection<T> { private object _itemsLock = new object(); public SortableObservableCollection() : base() { BindingOperations

What does “Resetting the connection” mean? System.Data.SqlClient.SqlException (0x80131904)

ぃ、小莉子 提交于 2021-02-11 13:31:02
问题 I know this is a bit vague, but I'm not being able to pinpoint the issue. When I run the a bit of code against a local database it runs fine. When I use a remote database I get an error. It occurs midway of the program execution. The DBup upgrade runs, and then a manual query fails with this exception: System.Data.SqlClient.SqlException (0x80131904): Resetting the connection results in a different state than the initial login. The login fails. Login failed for user 'sa'. I'm creating

Execution flow of a linq query

£可爱£侵袭症+ 提交于 2021-02-11 12:49:41
问题 case1 var numbers = new List<int>(); numbers.Add (1); IEnumerable<int> query = numbers.Select (n => n * 10); // Build query numbers.Add (2); //Use or execute query case2 var numbers = new List<int>() { 1, 2 }; numbers.Add(4); List<int> query = numbers .Select (n => n * 10) .ToList(); // Executes immediately into a List<int> numbers.Add(3); numbers.Clear(); //Use or execute query Why in the first case query contains both 1,2 In second case query contains only 1,2,4 but not 3,is it because we

How to implement pagedList on DbQuery Entity in Dbcontext without fetching full data in .net core?

独自空忆成欢 提交于 2021-02-11 12:49:06
问题 I have to execute a sql string in .net core so first I added a Dbquery type entity in dbcontext. internal DbQuery<TempData> MyDataList{ get; set; } Then I fetched the data with my sql string as var data = context.MyDataList.FromSql(dataqueryString).ToList(); Iam getting the data correct but need to implement PagedList on this without fetching the whole data from database. I have tried like var data = context.MyDataList.FromSql(dataqueryString).ToPagedList(1,10) But this will fetch whole data

Xpath to select elements that has specific child [duplicate]

孤街醉人 提交于 2021-02-11 12:44:49
问题 This question already has answers here : XPath - Get node with no child of specific type (5 answers) Closed 6 years ago . <item id=1> <name>item1</name> <price>30</price> </item> <item id=2> <name>item2</name> </item> I need an xpath to select only items that DO NOT have price for .net. 回答1: For your original question: item[price] will give you all item elements that have a price element child. This includes an empty <price/> so if you want to avoid matching <item> <name>item3</name> <price><

How do you redistort a point?

谁说我不能喝 提交于 2021-02-11 12:42:46
问题 I have a distorted image on which I use Cv2.Undistort() which straightens it out. After this I find some points in the image. I need to get the location of those points in the distorted image. I have tried Cv2.ProjectPoints() but failed to get appropriate coordinates. They were outside the bounds of the image. This is how I went about doing this: List<float> arr = new List<float>(); foreach (var i in points) { arr.Add(i.X); arr.Add(i.Y); arr.Add(0); } Mat pointArr = new Mat(3, points.Count,

Tasks combine result and continue

一曲冷凌霜 提交于 2021-02-11 12:41:01
问题 I have 16 tasks doing the same job, each of them return an array. I want to combine the results in pairs and do same job until I have only one task. I don't know what is the best way to do this. public static IComparatorNetwork[] Prune(IComparatorNetwork[] nets, int numTasks) { var tasks = new Task[numTasks]; var netsPerTask = nets.Length/numTasks; var start = 0; var concurrentSet = new ConcurrentBag<IComparatorNetwork>(); for(var i = 0; i < numTasks; i++) { IComparatorNetwork[] taskNets; if

Mailkit imapclient working with console application but not working as windows service

一笑奈何 提交于 2021-02-11 12:35:46
问题 I've created an email notification console application using mailkit's idleClient sample code (https://github.com/jstedfast/MailKit/tree/master/samples/ImapIdle). The purpose of this application is to fetch all new emails and trigger web api's based on the content of the email. It works fine as a console application. But when I converted it into a windows service using Topshelf and hosted it in a server environment, the protocol logger is not able to write anything to the logs and the onCount