Tag: Linq To Sql

[HowTo] [SQL] Insert data in a column with default value with Linq

Il suffit de jouer avec les paramêtres AutoSync et IsDbGenerated dans les propriétés du champs que l’on veut traiter. il suffit de mettre la valeur AutoSync.OnInsert dans la propriété AutoSync et true dans la valeur IsDbGenenrated Voici plus de détails : [Column( Storage=”_Id”, AutoSync=AutoSync.OnInsert, DbType=”Int NOT NULL IDENTITY”, IsPrimaryKey=true, IsDbGenerated=true )] Ces paramètres sont accessibles […]

[HowTo] Linq Count Granchild items from an object with .SelectMany()

Lets say you have the following structure : Product    -> Zone       -> Category          -> Item Meaning a Product has multiple Zones with multiple Categories with multiple Items Lets say we need to select the count of items for each product in a simple distinct list of product. Linq query using .SelectMany() : xyzDataContext dc = […]

Handling Multiple Result (Shapes) from SPROCs

Handling Multiple Result Shapes from SPROCs [Function(Name = “spGetWebAccount”)] [ResultType(typeof(Client))] [ResultType(typeof(User))] [ResultType(typeof(UA_User))] public IMultipleResults spGetWebAccount(System.Nullable<Int64> ClientID, System.Nullable<Int64> UserID) { IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), ClientID, UserID); return (IMultipleResults)result.ReturnValue; } Source : http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx

[LINQ] The query results cannot be enumerated more than once (using databinding…)

When you bind the ISingleResultfor the first time, the results are enumerated and the data object is populated. When you bind the same ISingleResult instance to the same control again, it detects that the data-source is the same as its last source (by comparing their object references) and does not enumerate the ISingleResult instance for […]

DataGridView datasource : Use BindingSource or direct query ???

LINQ to SQL translates LINQ queries to SQL for execution on a database. The results are strongly typed IEnumerable. Because these objects are ordinary common language runtime (CLR) objects, ordinary object data binding can be used to display the results. On the other hand, sorting and change operations (inserts, updates, and deletes) require additional steps. […]