linq to sql: join multiple columns from the same table
This is the only way I was able to get it to work (in c#). var qry = from t1 in table1 join t2 in table2 on new {t1.ID,t1.Country} equals new {t2.ID,t2.Country} …
This is the only way I was able to get it to work (in c#). var qry = from t1 in table1 join t2 in table2 on new {t1.ID,t1.Country} equals new {t2.ID,t2.Country} …
C# has Convert.ToInt32() which should do what you’re looking for.
This might work… from p in db.products select new { Owner = (p.price > 0 ? from q in db.Users select q.Name : from r in db.ExternalUsers select r.Name) }
Well, I do not agree that the injection is not possible in Dynamic Linq. What described in the answer by Ɖiamond ǤeezeƦ is correct but appies to standard Linq as constructed within the given language – C# or VB.Net or by calling extension methods like .Where with lambda functions. Then, true, it is not possible … Read more
LINQ to SQL forces you to use the table-per-class pattern. The benefits of using this pattern are that it’s quick and easy to implement and it takes very little effort to get your domain running based on an existing database structure. For simple applications, this is perfectly acceptable (and oftentimes even preferable), but for more … Read more
Change where (s.crmc_Retail_Trade_Id == tradeId) to where (s.crmc_Retail_Trade_Id == tradeId || (tradeId == null && s.crmc_Retail_Trade_Id == null)) Edit – based on this post by Brant Lamborn, it looks like the following would do what you want: where (object.Equals(s.crmc_Retail_Trade_Id, tradeId)) The Null Semantics (LINQ to SQL) MSDN page links to some interesting info: LINQ to … Read more
You can code your original query: var query = from tags in db.TagsHeaders where tags.CST.Equals(this.SelectedCust.CustCode.ToUpper()) && Utility.GetDate(DateTime.Parse(this.txtOrderDateFrom.Text)) <= tags.ORDDTE && Utility.GetDate(DateTime.Parse(this.txtOrderDateTo.Text)) >= tags.ORDDTE select tags; And then based on a condition, add additional where constraints. if(condition) query = query.Where(i => i.PONumber == “ABC”); I am not sure how to code this with the query syntax … Read more
Entities that are part of the data context can not be created using a LINQ query. This is a well thought design decision of the C# team. Because the entities are newed up (manually) in the Select statement, this would mean that they are not tracked by the DataContext and this can confuse developers. On … Read more
Assuming: public class Person { public string LastName { get; set; } } IQueryable<Person> collection; your query: var query = from p in collection where p.LastName == textBox.Text select p; means the same as: var query = collection.Where(p => p.LastName == textBox.Text); which the compiler translates from an extension method to: var query = Queryable.Where(collection, … Read more
If you’re in Server Explorer, you can make them visible this way: Create a connection to the server you want. Right-click the server and choose Change View > Object Type. You should now see System Tables and User Tables. You should see sysjobs there, and you can easily drag it onto a .dbml surface.