score:2
Accepted answer
var dt = new datatable();
dt.columns.add("lastname", typeof(string));
dt.columns.add("firstname", typeof(string));
dt.columns.add("midname", typeof(string));
while (streamreader.peek() > 0)
{
string[] currentrowvalues = streamreader.readline().split(delimiter);
string lastname = currentrowvalues[columnheadertolocationy["lname"]];
string firstname = currentrowvalues[columnheadertolocationy["fname"]];
string middlename = currentrowvalues[columnheadertolocationy["mname"]];
dt.rows.add(lastname, firstname, middlename);
}
var data = new sqlparameter("data", sqldbtype.structured);
data.typename = "dbo.udt_providerimport";
data.value= dt;
// use this if you're inserting directly from the stored procedure:
context.database.executesqlcommand("exec dbo.usp_importproviderifeligible @data", data);
// if you're returning the new records for further processing,
// create a type to hold the returned values, and use:
// var results = context.database.sqlquery<resulttype>("exec dbo.usp_importproviderifeligible @data", data);
score:1
var textlist = new list<textentry>();
//load all the entries from the text file
var providersindb = context.providers.where(p => textlist.any(t => p.firstname == t.firstname && p.lastname == t.lastname && p.midname == t.middle));
var textentriesnotindb = textlist.where(t => !providersindb.any(p => p.firstname == t.firstname && p.lastname == t.lastname && p.midname == t.middle));
//add those text entries
Source: stackoverflow.com
Related Query
- Passing a collection of item to search for in LINQ
- Using LINQ to search two lists for match and return boolean for every item
- Search a collection for a sub type in C# / Linq
- Search List for an item and get the entire entry with LINQ
- How to execute a linq query for each item in a list , use it in the where clause and return a collection from the result of each query?
- Linq how to query a list of items for a combined list of a child collection based on a property of the parent item
- Wildcard search for LINQ
- Search two lists for at least one match with LINQ
- Can LINQ use binary search when the collection is ordered?
- How to add an item in a collection using Linq and C#
- Using LINQ to search a byte array for all subarrays that start/stop with certain byte
- Default value for linq select item if query didn't return anything
- LINQ to SQL - How to efficiently do either an AND or an OR search for multiple criteria
- Use Lambda or Linq to create Model of SelectList with Selected item for razor View in MVC5
- Change item in collection with LINQ
- Linq performance for in-memory collection
- LINQ search though a list of string arrays for a particular string
- Joining parent and child collection in LINQ for a single merged output
- Need a linq to objects query for a nested collection
- Return Type for Collection from LINQ Query
- C#'s LINQ for collection manipulation equivalent in ruby
- Linq statement to iterate through a collection and making sure each item is in the correct order?
- Using LINQ vs SQL for Filtering Collection
- Remove an item from a LINQ collection
- linq query for tag system - search for multiple tags
- Is there a more succinct Linq expression for inserting a constant between every item in a list?
- Linq equivalent for collection contains at least x items; like .Any() but instead .AtLeast(int)
- LINQ query for finding one item in list AND verifying list does not contain another item
- Replace a collection item using Linq
- Can LINQ be used to search for multiple Regex expressions in a string?
More Query from same tag
- Entity Framework linq query to return sub collection
- Groups the specified bookings based on their consecutive dates
- Get Range of integers with linq
- Asp.net mvc Linq query for multiple filters
- LINQ Query Incorrect Results Using AND and AND OR
- How to check if String contains any of the strings in List/Array
- Linq OrderBy issue when converting string to int with space
- List<T> Where T is custom object. Remove duplicates by property
- What will be optimized version of the given code?
- LINQ dynamic query with Where clause
- How to select values and key in a Dictionary of lists?
- Linq Select two colums of different types
- Linq With TakeWhile in C#
- Remove children nodes in XML using Linq
- LINQ to SQL - Left Outer Join with multiple join conditions
- Managing Blank field from Linq Query
- Instantiating Immutable Objects With Reflection
- How to convert list to json
- Linq filter by time range
- AddHours to Linq Date result
- Combining child class lists to parent class list
- Parsing incorrect html with HtmlAgilityPack
- left outer join problem
- Find matching IDs between two different List Objects only when all IDs or more are present?
- ASP.Net MVC - how can I easily serialize query results to a database?
- Return hierarchy from sql in lists in c# using linq
- Linq 'first' issue
- How to convert Infrastructure.DbQuery to ViewModel type?
- Replacing strings in a string array efficiently
- How can I write this LINQ query as a Lambda expression?