linq

How can i see execute command in Entity FrameWork ?

i try to use erpCtx.Executecommand but i doesn't have method of executecommand. i think that i must add dll in Reference to show executeCommand? i need : int rowsAffected = engCtx.ExecuteCommand("insert into ENG_MAINWP Values({0},{1},{2},{3})", engArray[0], engArray1, engArray[2], engArray[3]); ...

How can I use drop down list value (String) to filter linq results?

Hi, I'm filling a drop-down list using the following: var columnNames = db.Mapping.MappingSource.GetModel(typeof(StaffDirectoryDataContext)) .GetMetaType(typeof(Person)).DataMembers; I'm then converting that to a List<String> to populate a drop down list. I then want to be able to get a set of res...

Need help with LINQ to SQL WHERE-clause on foreign table

Let's say I have these two tables: ParentDataItem ParentDataItemID ...some other fields... ChildDataItem ChildDataItemID ParentDataItemID (foreign key) Name Value Now I want to select any ParentDataItems that have a ChildDataItem with a specified name and value. I know I was way off with my first approach, wh...

LINQ - Convert List to Dictionary with Value as List

I have a List<MyObject> that I retrieve from the database. However, I would like it keyed by a property in MyObject for grouping purposes. What is the best way with LINQ to cast my list to: Dictionary<long, List<MyObject>> I have the following: myObjectList.ToDictionary(x => x.KeyedProperty) But it returns: Dictionary<long, M...

Use LINQ to group by multiple columns and read values of ungrouped columns

I need to group a data table on multiple columns and also read data of un-grouped columns col1 col2 col3 col4 col5 col6 col7 col8 .. col16 Here i am grouping it on col1, col2 ... col6. But facing problems in reading values of col7 ... col16 var groupedRows = from myTable in table.AsEnumerable() group myTable by new ...

difference between linq to sql and entity framework

Hi fnds, There are lof of difference between Linq to Sql and Entity framework like Linq to SQL is one to one mapping and EF is many to many mapping and many other which can be found at http://stackoverflow.com/questions/8676/entity-framework-vs-linq-to-sql But here I am asking with EF and Linq to Sql, do we create Entities first and th...

Page Cycles - Right way to input data to database

I have a page that has a few textboxes and a dropdownlist. When a logged in user opens this page the boxes are filled with data that he has inputed before, he can change the data and update it by pushing a update button. There is also that dropdownlist which has a dynamically populated data for him to choose from. What is the best way t...

Type conversion issues when LINQ projecting into ADO.Net Entity Framework class

I'm running into some issues when constructing a query using LINQ and Entity Framework. My model is like this Merchants(MerchantId) AffiliateFeeds(AffiliateFeedId, MerchantId) ProductSKUs(ProductId, AffiliateFeedId) This snippet works well enough: // only get Merchants and AffiliateFeeds based on specific ProductSKU.Pro...

Select two datacolumns from a datarow in linq (vb.net 3.5)

Dim orders = From tt In testTable _ Order By tt.Item("OrderNumber") _ Select tt.Item("OrderNumber"), tt.Item("OrderId") This is breaking. Is there a way to do this? I would have thought it was easy enough. Obviously, I thought wrong.... ...

Need a Nested LINQ to XML query help

i have a XML file as follows: <?xml version="1.0" encoding="utf-8" ?> <publisher> <name>abc</name> <link>http://&lt;/link&gt; <description>xyz</description> <category title="Top"> <item> <title>abc</title> <link>http://&lt;/link&gt; <pubDate>1</pubDate> <description>abc</description> </item> <item> <title>abc</title> <link>http://&lt...

how to convert linq to xml query to string[]

here is my xml: <record> <id>12342</id> <name>xx</name> <blah1>asdfas</blah1> <blah2>asdfas</blah2> ..... </record> I would like to get all of the values and put it into a array. i tried the following, it returns "12342xxasdfasasdfas" instead of "12342","xx","asdfas","asdfas" var q = record.Elements("record").Select(r=>r.Value); s...

Using NUnit to test that an IEnumerable was sorted correctly (uses nested sort)

I'm using MVP with ASP.NET Web Forms. Being a good TDDer, I want to test all the important behaviors in my Presenter, including the default sort it applies to the result set retrieved from the service layer. The Presenter will be applying a nested sort via LINQ to Objects of the style: public IEnumerable<ViewModel> MyModel{ get ...

linq to XML as a gridview datasource

I'm trying to get all the email nodes for the customers in the sample xml and binding it to a grid. I can't seemt to get past the linq query! Sample XML: <group> <customer> <email>[email protected]></email> </customer> <customer> <email>[email protected]</email> </customer> </group> var query = from result in xml.Elements("custo...

Dynamic LINQ Query in LINQ to Entities , problem with WHERE clause

Hi, For the life of me, I can't figure out what the problem is with this: tempData= from a in dx.SomeTable select a; string searchField="ItemName"; string searchString="BoxPkg"; object[] parameters=new object[]{searchField,searchString}; tempData = tempData.Where("@0 like @1", parameters); I get this error " {"Expression of type '...

LINQ to Entities does not recognize the method

LINQ to Entities does not recognize the method 'Boolean Contains(Int32)' method, and this method cannot be translated into a store expression. var warranty_yes = from i in devicesEntities.device where i.WarrantyDate >= DateTime.Now select i.Id; var warranty_yes_list = warranty_yes.ToList(); var view_query = from i ...

Is this SQL query translatable into LINQ?

SELECT * FROM table1 JOIN table2 ON table1.center BETWEEN table2.left AND table2.right I'm new to LINQ, and I've seen that 'join' require an 'equals' keyword (instead of BETWEEN in my SQL). Perhaps I could override 'Equals' operator and create a new object of a LINQ query? ...

How to use Case Conditions in LINQ To DataSets

I have a DataTable containing some records. Based on some conditions I have to filter records into two datatables. Say When row["ItemType"]==1 //Insert item into DataTable 1 When row["ItemType"]==2 //Insert item into DataTable 2 Else //Insert item into DataTable 3 How to do this in LINQ for a DataTable that contains a...

LINQ to SQL filter by List<int>

Hello, How can I retreive rows from table only when UserId is in my Users list ? Code below doesnt work :/ List<int> selectedSourceUsers = ... MyModelDataContext context = ... e.Result = from u in context.Users from id in selectedSourceUsers where u.UserId == id select u; Tha...

Convert list of one type to list of another type in C# 3.5

I have an object, with ID and Name properties. I have a list of the objects, but I want to convert it to a list of strings containing the name of the object. I'm guessing there's some fancy Linq method that will put the name of the object into the list. List<string> myObjectNames = myObjectList.? ...

Databinding with Data Template on ComboBox Select Item using LINQ

Hi Folks, I have a little Problem. A SP give me a several list of URL´s. The Urls are binded on a Combobox. When i Select an Item, always the Object comes to the Combobox not the Selected Value, see the code below: <DataTemplate x:Key="Webadressen" DataType="{x:Type src2:GetWebadressenResult}" > <StackPanel> <Label Content="{Bindin...