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
- Operator '==' cannot be applied to operands of type 'method group' and 'string'
- Error in Linq Expression GroupBy in .NET Core 3.1
- How to set multiple property values with same name and counter value using reflection?
- How to catch an exception only if another exception as not occured in C#
- Why is this implemented as a struct?
- Split field a string and compare each value with string linq c#
- Linq Query Multiple DataTables in DataSet
- C# and LINQ - arbitrary statement instead of let
- How to compare only dates in linq?
- Making a new DataTable out of two others with same ID using LINQ in C#
- LINQ query for getting row with max date in grouped table
- Correct Linq conversion from C# to Vb.net
- Entity Framework generic DbSet to List
- Creating A List To Contain LINQ Results?
- Linq Read XML with <br> tag
- C# DataTable Filter Fastest Way
- Find Object in List<object> by same property
- How to replace null with Empty string in Expressions.Expression in c# Linq
- How to select record from XML using LINQ?
- Flattened records to parent/child objects using LINQ. Without duplication of data
- Linq where condition not working
- List reference issue c#
- Attempting to build a Neo4j Repository
- How to LINQ DataTable with group by and order by to deduplicate data
- Orderby clause not working with drop down list in mvc
- IOrderedQueryable Skip and Take
- C# Convert a DataTable to List<string>
- LINQ to Entities query to DataTable
- Error, method not supported by LINQ to Entities
- C# Linq List Compare and update lists