Linq Questions
Ad
Linq to SQL: Asking if a date is empty
I've got a new instance of an object in a linq dbml, but don't know of the test if the a date field is empty. i have tried:
Checking if a list is empty with LINQ
What's the "best" (taking both speed and readability into account) way to determine if a list is empty? even if the list is of type
Good sophisticated linq to sql sample?
I am looking for a more sophisticated way of using linq to sql. i am leaning l2q but i am only seeing simple examples of business objects and
Limiting results of System.Data.Linq.Table<T>
I am trying to inherit from my generated datacontext in linqtosql - something like this public class mycontext : dbdatacontext {
How to return a page of results from SQL?
Many applications have grids that display data from a database table one page at a time. many of them also let the user pick the number of records
How does SQL know what @p# in LINQtoSQL queries?
I want to know how does the sql server know what @p# is in say this linqtosql query select [t0].[memberid],
What to do about @p LINQtoSQL parameters? What is @p anyhow?
Okay still fighting with doing some sqlcachedependecy in my asp.net mvc application i got this piece of code from microsoft to cache
Filter EntityDataSource on Association value
I really like entity framework, but there are some key pieces that are a challenge to me. can anyone tell me how to filter an entitydatasource on
LinqtoSQL filter and order by syntax
My techie bretheren (and sisteren, of course!), i have a linqtosql data model that has the following entities:
Filter linq list on property value
I have a list<int> and a list<customobject>. the customobject class has an id property. how can i get a
Ad
Is there a pattern using Linq to dynamically create a filter?
Is there a pattern using linq to dynamically create a filter? i have the need to create custom filtering on a list, in the past i would
When to use an extension method with lambda over LINQtoObjects to filter a collection?
I am prototyping some c# 3 collection filters and came across this. i have a collection of products: public class myproduct {
Linq To SQL: Can I eager load only one field in a joined table?
I have one table "orders" with a foreing key "productid". i want to show the orders in a grid with the product name,
Algorithm for Fogbugz pricing scheme
I'm looking for an algorithm to calculate total cost of licenses purchased based on the "fogbugz for your server" pricing scheme
How much database performance overhead when using LINQ?
How much database performance overhead is involved with using c# and linq compared to custom optimized queries loaded with mostly low-level c,
XDocument: Could not find file 'C:\Program Files (x86)\IIS Express\myfile
Here's my code dim doc = xdocument.load("web.sitemap") i'm trying to load the an xml file so that i can
How to handle programmatic addition of fields?
Yesterday, i asked this question regarding best
LINQ to entities - Building where clauses to test collections within a many to many relationship
So, i am using the linq entity framework. i have 2 entities: content and tag. they are in a many-to-many relationship
How to insert a new ListItem Record into Entity table using ASP.NET
I want to inserd new record into my entity table. while binding the records to dropdownlist, we add one new listitem like "- select one
Select a ListItem from DropDownList using a Linq Query
I' trying to use a linq query to find and set the selected value in a drop down list control. dim qry = from i in
How do I not return {ModuleName = Admin} from the linq query?
I am trying to get the string value "admin" from a linq query, but when i do: string oldmodule = dc.modules
Ad
How to generate xsi:schemalocation attribute correctly when generating a dynamic sitemap.xml with LINQ to XML?
I am generating a dynamic sitemap.xml according to
Issues querying google sitemap.xml with Linq to XML
I have a linq-2-xml query that will not work if a google sitemap that i have created has its urlset element populated with attributes but will
Multiple posts to DB with Linq
If i have two thousand webusers each sumbmitting a post to sqldb through website at the same time same tables, will linq handle this without any
Create LINQ intermediate variable the way .Select it does
I created the following extension: public static class stacktraceextensions { public static string callers(this stacktrace
I need a LINQ expression to find an XElement where the element name and attributes match an input node
I need to replace the contents of a node in an xelement hierarchy when the element name and all the attribute names and values match an input
Selecting author name field from Atom feed using LINQ (C#)
I'm trying to select the "name" field from the author node in an atom feed using linq. i can get all the fields i need like so:
Am I missing something about LINQ?
I seem to be missing something about linq. to me, it looks like it's taking some of the elements of sql that i like the least and moving them
How to get all values associated with the same key in a list of dictionaries?
I have a class that looks like this public class vegetablespricenode { public string country{get;set;} public
Check if 2 int arrays contain only unique numbers at the same index
If i have 2 int arrays a and b and they contain data like this.. a[0] = 1 a[1] = 3 a[2] = 7 b[0] = 6 b[1] = 3 b[2] =
Why is my ASP.NET AutoCompleteExtender returning undefined?
Why am i getting a textbox that returns undefined list of variables? when i run this code: var query = (from tisa in
EF Core 6 – ToQueryString() on a query created with FromSqlRaw thows exception "Sequence contains no elements"
It is the first time i'm using the query mode of ef core. because my large query with parameters threw also the exception "sequence contains
Ad
LINQ Compare TimeSpan
In my database a have rows like
How to group and sum up in a LINQ like manner in JavaScript
I'm getting crazy about that. maybe you could help. assume having the following .net classes: teacher:
Filtering IEnumerable<T> dataset with T as Dictionary<string, object>
There is a data set as ienumerable<t> griddata which is bound to a data grid. in one scenario data loaded with t
Return only unique(distinct) element based on certain properties from an array
I am looking for a way to return only distinct elements in an array but that has to be based on a certain property, other properties of the array
Fetch element with common id among two array but id must be unique for each sets of arrays in C#
I am trying to fetch elements having a common id from 2 sets of arrays but that id must be unique to each array, the array can contain
Skip an empty sequence inside a LINQ .Where statement
I have an array of tuple arrays like this: (type, func<int, bool>)[][] formats; i also
Group by and count in C# w/ Console.WriteLine
I'm trying to console.writeline my answer but i am missing something and after 2 hours of searching, i just can't figure it out. i want my
How to know if a DateTime is Between two Dates in Entity Framework Core
I have an application and a database created by entity framework core, i have an entity called listusers with this property:
Combining Objects into a new model with Linq/Lambda expressions
I am working on a blazor project and using dapper to pull data from a sql db. i am pulling 3 tables at the moment. an entity table, a specialty
Linq query on arrays of tuples
(type, int)[] format1 = new[] {(typeof(foo),1)}; (type, int)[] format2 = new[] { (typeof(bar), 1),(typeof(baz),1) };
Better way to update/insert values using EF
I am trying to solve a problem as well as learn and improve my code skills here. i am using entity framework and am tasked with writing to
Ad
How to group a class by date and select Max(Date), primary-key and foreign-key?
I need to reduce data from a class as given below (pk ... primary key, fk ... foreign key):
LINQ query grouping without duplication of data
So i want to display an output that is group by two fields: subsidiarycode and assetcreateddate. my problem is it
NHibernate Object References to null in Where clause
I have an isession.queryover code block. in where clause, there is a problem as shown below var receipts= isession.queryover(()
Get the count by type in a List
I am having trouble getting the count by its type.
LINQ max date with join and group
I can't figure it out and tested some answers from similare questions. now i need a linq pro. :) the following query with linq returns each
How can I compose this LINQ expression?
I am creating a web application to manage a flight school and i have the following database structure (unrelevant tables have been blurred and
.NET Core: How to merge nested one-to-many relations in dto
How could merge nested child entity in parent? i have these three entities: public
How can i simplify this into one line
Portalselectslist.firstordefault(x => x.portalid == item.portalid).accesstypeportalid = item.accesstypeportalid;
Entity Framework expression to SQL translation
Look at this iqueryable: var query = from e in db.entitya select new myviewmodel {
what is Javascript .map equivalent in vb?
I'm trying to make a simple script in vb that will transform a string "these are my characters" into this "these are my characters" it
Executing Linq query throws exception
I have a method in which i filter a table and return those rows that match the filer. here's the method: public
Ad
Reading data from database in Linq-to-SQL
I have this class: public class student1 { public string name { set; get; } public string number { set;
Insert a List<String> to a ntext field using Linq to sql
I have this class: public class course { public string name { set; get; } public int code { set; get; } public
Ways to limit database calls? Specifically in ASP.NET MVC
So i have two repositories: repository a which gets info from database a and repository b which
How can I speed up this Linq to SQL query?
So, i have a function that returns data for use in a gridview. it takes ages to complete (about 25 seconds). i think i've written it very badly
Which is the best book out there to learn Linq, including Linq to Entities?
I heard lots of reviews on the book linq in action, but it does not cover linq to entities. please provide your feedback on the books you
LINQ Group with nested list
I'm trying to group my data using linq. this is the model i use: public class employee { public string firstname {get;set;}
Querying a DataTable filtering for first char in field
I am new to linq & i can't figure out this query. i have a datatable with has a field "recordtype" i want to get certain row
How can I refactor this EF Core query to add another where condition variable?
I have this query below that looks for a transfer with a user id in either the senderid or receiverid column. //
How to unflatten a list of objects?
I'm trying to convert an object to a dto public class topology { public int a { get; set; } public int b { get; set; } }
C# LINQ nested WHERE IN query
I have the following sql query and i want to convert it to linq expression select `a`.* from `action` as `a` where `a`.`id` in (
LINQ to SQL Association - "Properties do not have matching types"
I am trying to link two fields of a given table to the same field in another table. i have done this before so i can't work out what is wrong this
Ad
How to create XElement with default namespace for children without using XNamespace in all child nodes
I'm trying to use system.xml.linq to create xhtml documents. thus, the vast majority of the nodes in my trees ought to use this
Do namespaces propagate to children in XElement objects?
If i have an xelement that has child elements, and if i remove a child element from the parent, removing all references between the two, will the
EF SQL query Performance on comma-separated string Ids
To store and query on associated ids, which method works best in terms of query speed and performance? especially in a large number of records in
Why Object reference not set to an instance of an object in LINQ Where for Two Column in ComboBox
I'm using c# wpf to connect to a database in sql server i have a combobox that have two column to display with one selectedvaluepath
How can I loop Through all the elements in .select statement in Linq
I am trying to print "title of the book , authornames " (some books have more than one author) below linq code is printing only first author. how
How to parallelize this query in Python (just like PLINQ)?
I'm having some issues with a query i wrote in python (have to use it for tensorflow), which works just fine but is way too slow, since the input
Counting active listings by month and year
I am currently working with real-estate data, and each listing entity has a listingdate and a closedate. what i am currently trying to do is to
Lambda Expression for FirstOrDefault with two parameters
I have a lambda expression that is passed to a first() or firstordefault() call. i would like to dynamically
Select fields in a matching array and parent with C# Linq
I have an object that i need to get some fields from just the first one matched. the key thing is "prices" will either be sorted in
How to manage multiple tables with the same structure (redux)
I found this question, which is similar to a problem that i would like to solve:
ValidationAttribute Redux
Ref to:creating a validationattribute
Ad
EF Core rewrite the query in a form that can be translated after upgrading
This query was working fine before we upgraded: var appusers = await _masterdbcontext .users
Building dynamic where query from linq to ef core
My model looks like below public class country { public int id {get; set;} public string name {get; set;} } public class user
Ignore dots in Convert.ToDecimal and return 0
I am using convert.todecimal in linq, sometime amount value coming as dot (.) as user might want to write .50 or something,
linq Group By and take first and lats records
I am dealing with probably simple yet difficult problem for me. i am taking photos of parked cars and save them by car's plate and timestamp it.
How to select only several columns from GroupBy... First()
I am trying to select "highest" licence user has per year. i started with: var lic = _context.licences
Is there a Vuejs equivalent for LINQ?
I'm new to javascript and i just wanted to know if there is a linq equivalent in vue. my goal is to do something like this :
Load only some elements of a nested collection efficiently with LINQ
I have the following linq query (using ef core 6 and ms sql server): var resultset = dbcontext.systems .include(system
c# updating a value inside a List<int> thats inside a dictionary<string, List<int>> using Lambda
Hey all i have a issue with trying to use lambda with my variable simply because its not a key, value type of setup. meaning i don't
C# Why IEnumerable and IEnumerable.ToList() print their result is difference?
I get the sequence number 0 ~ 2 with ienumerable and when i print the result. the ienumerable and ienumerable.tolist()
LINQ To Entity - Inner Join issue
I have two related tables like below : users : public partial class users {
ASP.NET Convert Invalid String to Null
In my application i have textbox in a formview bound to a linqdatasource like so:
Ad
How do I include multiple entities in one row in Linq?
Sorry if the title isn't clear, i couldn't think of a good way to summarise the question. suppose i have a database table called
Create a one to many collection from linq result setC#
I have a database table which contains one to many data collection. from that table i need to make a dictionary which represents the data. the key
C# - Match between items in List<Items> to ItemsContainer in List<ItemsContainer>
I have a list of items and a list of itemscontainer which is a class that holds items. all the items are unique every item
How to convert SQL (count, order by) to LINQ (count, order by)?
I have a query here and its working in sql, but i am using linq and i don't know how to convert it. can anyone help me? this is my
Sorting date in string format with possible invalid/null values
I am trying to sort date field in string format with invalid/null values. however, i am not getting the expected result. var
Linq one to many with filter
I have an entity framework database that i'm querying, so i'm using linq-to-entities. here's my query: // 'find' is just a wrapper
C# TakeLast Extension for .Net Framework 4.6 and newer versions
I'm looking for help finding an extension method for takelast that someone has written that can work for older versions of .net framework like 4.6
Localisation/I18n of database data in LINQ to SQL
I have status tables in my database, and "localised" tables that contain language-specific versions of those statuses. the point of the main
How to insert depending LINQ to SQL entities without manual ID update in C#?
I have 2 models. model foo [system.data.linq.mapping.table(name = ...)] public class foo {
LINQ query to return list where condition is based on another table
I have two tables cars and booking. i want the following sql query's equivalent in linq and i'm struggling with
How do I combine data from two rows with the same foreign key in sql/linq
I have a table for payslips which can contain multiple payslips with the same employee. each payslip has a hours_worked column. i want to be able
Ad
Grouping data via LinQ in Powershell
I have an array of data and i need to group them by 2 attributes and then calculate the sum of a third attribute per each group. i want to do this
How to specify where and select in a query containing ThenInclude, when either of where/select is not present in the query context?
I have 3 tables: contract, matter and claims. each table has a 1:n relationship with the following table. i want to select claim
Ad
Blog Categories
Ad