LINQ statement that returns rownumber of element with id == something?
How to write LINQ statement that returns ROWNUMBER of element with id == something? ...
How to write LINQ statement that returns ROWNUMBER of element with id == something? ...
Dim customers As List(Of Customer) = New List(Of Customer) For Each mbi In fordContracts customers.Add(mbi.Customer) Next Is it possible to query fordContracts for customers? It is an IList(of mbi) and each mbi object has an EntityRef to a Customer object. I just wanted to know if there was a better way to achieve this...
I know it's fairly straight forward to create Repository for retreiving domain models without ORM (http://stackoverflow.com/questions/446629/repository-pattern-without-linq-or-other-orm). However, what about saving domain models and its internal object graph? public class Car: IAggregateRoot, IEntity, ICar { public IEnumerable<IWheel>...
I am using linq-to-sql to load and save data to database. Since most of the data to save or load is user input and to avoid all possible risks of saving raw data, i decided to HtmlEncode the input.Here is the summary of what I do Encode the input before saving it to the database. Decode the input to be able to manipulate the raw data. ...
Dim entName = "Some Auto Dealer" Dim whereEntity As Expression(Of Func(Of Entity, Boolean)) = Function(en) en.ENTY_Name = entName Dim login = Repository(Of Entity).Create().FindSingle(whereEntity) Dim whereDealer As Expression(Of Func(Of Dealer, Boolean)) = Function(dlr) dlr.Entity.Equals(login) Dim dealer = Repository(...
I was recently taking a look at the Kazi Manzur Kigg MVC implementation (Kazi rocks) and noticed some code that seemed to defeat the DRY/SOC principle. I'd love to have everyone's thoughts on a possible refactor to separate concerns. Kigg implements both an Add and Remove method on each repository class ( Note: BaseRepository has virtu...
In straight SQL, I'd probably wrap some logic over a simple join, but how would I do this efficiently in LINQ to SQL? Imagine I have two tables: Parent ID Child ParentID ID Name Ideally I'd like a graph of Parent objects with a "Childs" property that is actually a Dictionary<int, string>. Suggestions? ...
Hello Everyone, I'm quite new to Linq and have had some problems updating my dabase. I don't know if it is actually happening for be using a global data context or I'm missing something. I have my typed DataContex and one Static Public Var to initialize it located within the namespace AlpaCommon, like following: My partial datacontext**...
In some (or many) ways linqtosql makes its hard to recreate a very easy sql. I've tried googling but couldn't find any answer on how to convert to linqtosql the code below with a left outer join that has one condition that should evaluate a column value to true. Thanks in advance to anyone who can help (preferably in c#). SELECT * FROM...
I'm fairly new to asp.net and especially LINQ and SQL. Say I have a table "Employees" with fields "Lastname", "Firstname", and "ID". I want to bind this to a list box. I want the list box to display it's contents like "$LASTNAME, $FIRSTNAME" and I want the value of each item to be "ID". It's trivial to bind either name column to the l...
This question led me to wonder the following: What are the 'Gotchas' associated with tacking on a ToList() to a Linq-to-Sql query? I'm equally interested in best practices and anecdotes. ...
I have an ASP.net site that is essentially just a user interface for a class library I created. Each of the classes in this class library contain a static definition class with static references to compiled queries. Like so: class MyRecord { /*Some Properties,Fields, and Methods*/ internal static class Queries { ...
Our application follows the approach of maintaining a DataContext per Thread/HttpContext, using the DataContextFactory class outlined by Rick Strahl on his blog, including the amendment to the Key mentioned by Richard (use of type.AssemblyQualifiedName). The solution appeared sound (although in most cases a different approach may be bet...
I can't find a template for a linq to sql class in .net 2.0 project, based on what i know you can work with linq in .NET 2.0 as long as you have 3.5 in your development machine and ship system.core.dll with your application? so based on that how can I add a Linq to Sql model to my project when "Linq to Sql Classes" template is missing ...
Good day! In our project we are using .NET RIA Services and Linq2Sql. To insert/update entity we've implemented some custom logic. On server side was written a method which call sp. The problem is that our method don't invoked because it can not be found! Implemented method on server side: public void InsertNewPolicy(Policy policy) { ...
Hello, I'm wondering if there is a way to retrieve the identity value from an identity column before saving a new register. When I run this query: "SELECT IDENT_CURRENT ('alpa_Animais') AS AnimalID" directly, using the SQL Server Management Studio I get this value. Does anyone know if there is a way to get this from a method inside a w...
I'd like to display a linq-to-sql on a datagridview as such: Dim myQ = From b In _dcBooks.Books Select New With {Key b.ID, b.Title, b.Genre, b.ISBN, b.Format, b.Series, _ .Author =b.BooksAuthors.Count()} the formula for the authors column is simplified as it would normally display nothing, the only author or "multiple". ...
I came across an interesting bug with linq to sql. Take a look at the code below which is loosely translated from a LINQtoSQL query from a search engine i'm writing. The goal of the query is to find any groups which have the ID's "Joe", "Jeff", "Jim" in consecutive order. Pay careful attention to the variables named localKeyword and l...
Would it be wise to use linq to sql on the tables generated by asp.net reg_sql tool? i would like to be able to do some operations on the dbo.aspnet_webEvents_Event table (purging the data base on date or event type for example). ...
The reason I ask is because the HttpContext.Current.Items collection seems like it would be a good place to put IDisposable objects such as a DataContext so that a Repository might access it transparently without having to to inject any dependencies related to a specific ORM technology into the Repository. This would also allow the repos...