I am iterating over the properties of various mapped tables in my code and need to know whether or not each property is lazy loaded. I have found that the instance variable used for storage, denoted by the Storage attribute on the property, will be of type System.Data.Linq.Link.
Is there a way that I can leverage these two facts at runt...
I have a table which stores cultural variants for a particular key for example.
RecordID Key CultureID Description
1 1 en-GB Hour
2 1 es-ES hora
3 2 en-GB Swimming
I have this as an IEnumerable Given the paremeter of @CultureID="es-ES" I want to return the following. ...
I'm implementing the repository "pattern" in my ASP.NET MVC application. So i was doing some reading to decide whether i should expose the entire DataContext (initializing it in the constructor) or just the table via .GetTable<T> when performance is the most important factor.
While doing my googling i ran into the following code at http...
Hi ,
Could any body clarify these two expression for me ?
What are cons and pros of each one ?
// I've just worked and familiar with CodeSmith and Linq to sql among all ORM Tools
Thank you
...
We're working on an ASP.NET web application with C# code behind. The database is MySQL 5.1 using InnoDB. The data access layer uses ADO.NET to call stored procedures and then builds various data structures out of the result sets (no object mapping). This works fine, but it is a little verbose.
Not surprisingly, we made some mistakes ...
This code should convert the list of listType2s (list) to a list of type1s. I feel the functionality is somewhat difficult to ascertain though.
I am looking to see alternative methods that are easier to read, yet concise, and brief.
List<Type1> type1s = new List<Type1>();
listType2s.ForEach(t => type1s.Add((new Type1(t...
I pull schedule data from a database via LINQ to SQL and hence use a DataContext object. The data defines when certain actions should be performed and can be updated independently of my service.
I periodically poll the database to see if the schedule has been updated and adjust my scheduling accordingly.
That is, I would, if I knew how...
I am trying to optimize a LINQ to SQL request so that it results in a single SQL statement. At the moment i have something like this:
EDIT : removed the "where" filter for clarity - also "Id" is a primary key in the databsse for both object types
hotel = (from h in db.Hotels
let rooms = (from r in db.HotelRooms
...
I'm trying to make an educated decision about what ORM to use for a number of legacy applications I'm responsible for porting to MVC 2. The ORMs I've looked at are LINQ to SQL, LINQ to Entities and nHibernate. L2S seemed to be the easiest, but I've found numerous articles and blog entries stating that Microsoft would no longer be updatin...
I have an nvarchar SQL column which contains mostly numeric values. I'm trying to come up with an L2S expression that gets me the maximum numeric value while ignoring any non-numeric values.
The SQL that does the job is:
select top 1 value from identifier where and patindex('%[^0-9]%', value) = 0 order by CAST(value AS INT) desc
What...
I really like PredicateBuilder. It allows me to build all sorts of queries very dynamically. The predicate variable can be passed around to different objects and they can add onto it with values they know about, etc. Except when I am needing to use a .Contains on a hashed collection. Bzzt! Crash and burn.
For instance (example/pseudo co...
I've implemented the repository pattern on the data access layer of our current service layer.
We have an object model where the same class "historical notes" is mapped on mutiple objects (currently 6 but soon to be more!)
Part of the best practices for the use of linq to sql is not to have one dbml file for every table in the db, but ...
Apologies for what may very well be a stupid question.
I'm just intrigued as to (a) will indexing improve performance (b) how will it improve performance and (c) why will it improve performance?
Also, if this does improve performance, would this be the case across the board for LINQ to SQL, LINQ to Entities, LINQ to Objects, etc, etc. ...
Hello!
I use linq2sql and m_DateContext.Dates class for table
ID | ParentID | Datestamp
---|----------|----------
1 | NULL | 1.8.2010
---|----------|----------
2 | 1 | 2.8.2010
---|----------|----------
3 | 1 | 4.8.2010
etc...
I need to write the linq query to select only rows where ParentID is NULL (ex: ID=1),...
How do I allow user to filter the DataGridView with a Linq to SQL source? I want to allow the user to filter on any field, like you would expect from Access or Excel.
With datasets, I could build up a query string and use that as a BindingSource filter. What's a good way do do the equivalent with Linq to SQL?
I could write a LINQ que...
I wanted to get any feedback (put out a feeler) for how the enterprise library plays with linq-to-sql generated classes. I was considering using the validation handler to provide validation logic/display to the UI level. I am considering the caching handler, validation, and authorization handlers primarily.
...
I've been playing around with Linq for a couple of days but i'm stuck with a bit of a problem here.
The query is this which follows:
select s.Nombre, emp.RFC,
isnull(sum(case when f.EsCancelada=0 then 1 else 0 end),0) emitidas,
isnull(sum(case when f.EsCancelada=1 then 1 else 0 end),0) canceladas
from serie s
inner join Empresa emp
...
I didn't use LINQ to SQL in project, I just went through a hand-on lab for Developing Data Access Logic with LINQ, one of the tasks is to create entity translator classes to translate between linq entities and business entities.
I am a little confused about this because I thought the reason we use LINQ to SQL is that it can auto gener...
I have a LINQ to SQL class (dbml) representing some tables in a database. I have added a "calculated field" of sorts by extending the partial class of one of the tables (Dwelling) with a new property (DwellingCode); this property takes the values of several database fields in the Dwelling table and generates a string.
So far, everythin...
I was reading Linq to Sql. Here I created a dbml file where I found that an autogenerated property has been created
[Column(Storage="_RecursionLevel", DbType="Int")]
public System.Nullable<int> RecursionLevel
{
get
{
return this._RecursionLevel;
}
set
{
if ((this._RecursionLevel != value))
{
...