How to get attribute in the XDocument object
You need to get the attribute of the <audio> element: string value = xdoc.Root.Element(“audio”).Attribute(“first”).Value;
You need to get the attribute of the <audio> element: string value = xdoc.Root.Element(“audio”).Attribute(“first”).Value;
As noted in the comments, add using System.Data.Entity (under the Entity Framework package) to get the QueryableExtensions. For .NET Core, these methods are under Microsoft.EntityFrameworkCore
I think you want HashSet.Except. That is, rather than use Lists, use HashSets, and then the operation is available. This is a better type if what you are representing is really a ‘set’ anyway. (If you already have a list, you can just create a ‘new HashSet’ out of it.)
There are multiple ways 1) var data = (from p in db.people orderby p.IdentityKey descending select p).Take(100); 2) var query = db.Models.Take(100); 3) or you can skip certain results var data = (from p in people select p).Skip(100);
The default value of any type T is default(T), so for 100% theoretical accuracy you would write if (!mapping.Equals(default(KeyValuePair<string, int>))) { // … } Since KeyValuePair is a struct (i.e. a value type) you cannot compare it to null. Irrespective of that, comparing values with == is wrong as a default approach because if used … Read more
You can chain your where clauses. You just need an IQueryable datasource. var filteredData = _repository.GetAll(); //If your data source is IEnumerable, just add .AsQueryable() to make it IQueryable if(keyWordTextBox.Text!=””) filteredData=filteredData.Where(m=>m.Keyword.Contains(keyWordTextBox.Text)); if(LocationDropDown.SelectedValue!=”All”) filteredData=filteredData.Where(m=>m.Location==LocationDropDown.SelectedValue)); … etc…. Because it is IQueryable, the data is not fetched until you bind it so it only pulls the data you … Read more
From the Queryable.Distinct documentation; The expected behavior is that it returns an unordered sequence of the unique items in source. In other words, any order the existing IQueryable has is lost when you use Distinct() on it. What you want is probably something more like this, an OrderBy() after the Distinct() is done; var query … Read more
The example you provided can by made simpler by dispensing with the anonymous type: var result = first.Zip(second, (f, s) => new[] { f, s }) .SelectMany(f => f);
That can’t be converted to SQL. I guess, in theory, it could, but isn’t implemented. You just need to perform your projection after you have your results: var pricingSecurityID = (from m in dbContext.Reporting_DailyNAV_Pricing select m.PricingSecurityID).AsEnumerable() .Select(x => new SelectListItem{ Text = x.ToString(), Value = x.ToString() });
Use FirstOrDefault instead of First. This will return null in the face of an empty collection. IRepository<User> = new UserRepository(); User user = userRepository.FirstOrDefault(u => u.Name == userName);