June 2008 - Posts

1
Comments

Synchronizing AutoGenerated Properties After SubmitChanges by zhirani

When you insert or update a record in the database, there are certain columns whose values are either generated because they are identity columns, or columns whose value is assigned by SQL server such as timestamp column. You could have triggers that...
2
Comments

ExecuteQuery to execute dynamic SQL in Linq To SQL by zhirani

If you find that a particular query is hard to represent as a Linq query, you can consider other options such as writing your own SQL statements inside of a stored procedure or a function and than calling the stored procedure and function using Linq to...
0
Comments

Executing Aggregates on SQL Server using Linq To SQL by zhirani

Linq to SQL support many aggregates such as Sum,Avg, Min, Max and few others but they may not execute on SQL server. Depending upon how you write your queries, you would be surprised the same syntax would actually bring the entire data from the server...
2
Comments

Change Notification In Linq To SQL by zhirani

If you have generated your Linq to SQL classes using visual studio Designer or used sqlmetal utility, you would notice that your entity classes implement two very important interfaces for change tracking called INotifyPropertyChanging and INotifyPropertyChanged...
0
Comments

Sorting eager loaded Child Collections With Linq To SQL by zhirani

By default Linq to SQL would lazy load all your child collections like when you have an instance of customer, its Orders are not loaded. ON traversing the Orders collection,  Linq to SQL fetches the Orders for that customer. You can use LoadWith...
1
Comments

Understanding Association Attribute by zhirani

If you have defined foreign key constraints on your tables in the database, LINQ TO SQL would generate Association attribute on both sides of the entity meaning the parent and child entities. Let's look at the association attribute generated by Linq To...
4
Comments

Inheritance in Linq To SQL by zhirani

When you are programming in .net, you can apply inheritance and polymorphism concepts on your entity classes to solve your business problems. However when you are saving those objects to the database, there is no clean way to store different child entities...
0
Comments

Retrieving AutoGenerated Id from the database by zhirani

Most of us don't have to worry about how linq does all the magic in the background of persisting our objects and syncing up our primary keys that are auto generated in the database. However if you are manually creating your class it is good to know what...
1
Comments

Using Storage Attribute to bypass property accessor by zhirani

For every column in the database, linq to SQL generates a property that maps a particular column in the database to the property defined on the entity class. However if you look at the setter property generated by the designer, it has all the details...
0
Comments

Table Valued function and Eager Loading Does not work by zhirani

Table valued function are nice way to apply further transformations to your linq queries. The reason is, they return IQueryable instead of stored procedure returning IEnumerable. I will not delve into the original problem that I was facing at work, but...
More Posts Next page »