score:2
Accepted answer
that executes the same query 4 or 5 separate times, although connection pooling will reuse a single connection. should be
var query = from e in ctx.bio_employee.where(x => x.emp_id == emp_id)
select new
{
ta.ta_system
,ta.bio_consent_flag
,e.bio_consentform_rid
};
var result = query.firstordefault();
if (result != null)
{
vm.tasystem = result .ta_system;
vm.bio_consent_flag = result .bio_consent_flag == null ? "n" : result .bio_consent_flag.trim().toupper();
vm.employee_bio_consentform_rid = result.bio_consentform_rid;
}
Source: stackoverflow.com
Related Query
- How many database calls in this EF query?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How to optimize this LINQ to EF/Sql query (many to many to many relationship)?
- How to write this linq query to avoid too many query?
- How to code this LINQ query in a better way
- how to write a Linq query with a EF code first Many to Many relationship
- How many SQL Queries will be executed in the database through this EF
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- What does this C# code with an "arrow" mean and how is it called?
- How do I translate this GROUP BY / MIN SQL query into LINQ?
- How do I write this cross apply query in LINQ-to-SQL?
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- How to write this query in Linq2Sql
- How to write this Linq SQL as a Dynamic Query (using strings)?
- How do I query only a single item from a database using LINQ?
- How does this linq code that splits a sequence work?
- How to improve this query performance in Linq?
- How can I combine this code into one or two LINQ queries?
- How can I query this hierarchical data using LINQ?
- How to turn this LINQ query to lazy loading
- How to query this two XML files using C#?
- linq - how do you do a query for items in one query source that are not in another one?
- How can I write the following code more elegantly using LINQ query syntax?
- How can I further simplify this piece of LINQ code
- How to dynamic add filters to a LINQ query against an Odata Source in C#
- How to write this nested Linq To Xml query
- How to improve this LINQ query for search
- How to render this map-reduce javascript code to an equivalent LINQ Select-Aggregate?
- How to convert this Linq query syntax to method syntax?
- How can I modify this C# code so that Visual Studio recognizes that I'm not an idiot?
More Query from same tag
- Doubts about how to read XML with Linq
- LINQ Remove items from collection if not in datatable
- How to get element value by using attributes in Linq to xml?
- Get specific data from a JSON
- An item with the same key has already been added
- Unable to retrieve a value from JSON, getting 'Cannot cast Newtonsoft.Json.Linq.JArray to Newtonsoft.Json.Linq.JToken.' exception
- Split duplicates in lists using LINQ
- Which one is better for getting the last row of my table with linq to nhibernate?
- C# For Loop with LIST using LINQ
- Filter query by multiple parameters from the list of objects
- Linq Groupby Sum a nested observable collection
- linq sum in vb.net
- how to sum the values from an XML file based on certain criteria
- Linq - how to replace a lists property with value from another list where both keys are equal
- How to read all lines from notepad comma separated and updated specific column conditionally in C#
- Select section of list based on value of a enumeration
- Most popular GroupBy with Linq to Entities
- Getting data from multiple tables (C# Entity), linked by foreign keys, converted to anonymous object
- Linq extract a count() value from a data object
- Return a single object from a list of C# objects checking for matching properties
- c# XML to linq error if null
- How to query XElement with two namespaces
- Linq filtering a list by a composite key (contains and not contains)
- Combine two list of lists in LINQ
- Need help converting SQL into LINQ
- LINQ Complex Query
- The LINQ expression contains references to queries that are associated with different contexts
- EF6 query building to get the first object in the list
- I need all values in one list that "connect" to all values in another list
- LINQ Group by with sort