I'm using linq to sql. I have a table in dbml file that some of its fields can be generate dynamically (at run time). Is there any way to add fields to a table dynamiccaly , or add a class to dbml file dynamically?
...
As two parameters i say currentPage and pagesize .....I thus far used sql server stored procedures and implemented paging like this,
GO
ALTER PROCEDURE [dbo].[GetMaterialsInView]
-- Add the parameters for the stored procedure here
@CurrentPage INT,
@PageSize INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result se...
The following code doesn't seem to get the correct count.....
var materials = consRepository.FindAllMaterials().AsQueryable();
int count = materials.Count();
Is it the way to do it.... Here is my repository which fetches records...
public IQueryable<MaterialsObj> FindAllMaterials()
{
var materials = from m in db...
I have recently started using custom ViewModels (For example, CustomerViewModel)
public class CustomerViewModel
{
public IList<Customer> Customers{ get; set; }
public int ProductId{ get; set; }
public CustomerViewModel(IList<Customer> customers, int productId)
{
this.Customers= customers;
this.Product...
I have a stored procedure that returns a result set (4 columns x n Rows). The data is based on multiple tables within my database and provides a summary for each department within a corporate. Here is sample:
usp_GetDepartmentSummary
DeptName EmployeeCount Male Female
HR 12 5 7
etc...
...
Hello,
I use LINQ queries in my ASP.NET MVC application and want to use OutputCache in some of my Actions.
I hear this should be possible with CommandNotifications. But those seem to only go for self-created SQLCommands, or am I wrong?
Can I manually tell SQL server to send SQLDependency notifications if certain tables change? And if...
I've written some really nice, funky libraries for use in LinqToSql. (Some day when I have time to think about it I might make it open source... :) )
Anyway, I'm not sure if this is related to my libraries or not, but I've discovered that when I have a large number of changed objects in one transaction, and then call DataContext.GetCha...
Thanks for taking a look at my post.
I've been working with linq to sql and have generally been happy, until i just noticed that database table names are hardcoded into the classes/dbml files-- which can't work in our environment. We need to be able to have database names completely changeable via web.config-- in one place. That's a def...
I'm trying to use Linq to SQL to return an IQueryable(of Project) when using foreign key relationships. Using the below schema, I want to be able to pass in a UserId and get all the projects created for the company the user is associated with.
DB tables:
Projects
Projid
ProjCreator FK (UserId from UserInfo table)
Companyid FK (Co...
I'm having issues when trying to insert nvarchar values in sql server with a linq-to-sql + c# program.
Here is the code:
public partial class Recipient
{
private static object _recipientLock = new object();
public static Recipient Find(string email, string displayName,
MyDataContext db)
{
...
Hey,
Am new to LINQ, and am trying to retrieve the top 50 rows of a particular table.
In SQL Server using an actual query i coudl say "Select TOP 50 from Transactions" , but not sure how i need to do that with LinQ
Any pointers that could help ?
Thanks !
...
I am rolling through all the cols on a particular row for processing. I am looking in general to replace using ado.net with L2S or some dynamic sql that can positionally read the columns on a particular row for processing.
This is my test code. I apologize for inefficiencies like sending the DataTable down to find the col name. It is a...
As we can’t trust our customers to update the index stats etc in sql server, we have in the past had to use index hints. (As some of our customers are still on Sql Server 2000, we also can’t depend on the better query optimizer in later version of Sql Server).
So how do I pass in index hints when using LinqToSql to build a query rathe...
I have a LINQ to SQL query returning rows from a table into an IQueryable object.
IQueryable<MyClass> items = from table in DBContext.MyTable
select new MyClass
{
ID = table.ID,
Col1 = table.Col1,
Col2 = table.Col2
}
I then want to perform a SQL "WHERE ... IN ...." query on the results. This works fine using the following. (return ...
I have a table that looks like this:
ID / Description / textValue / dateValue / timeValue / Type
1 / FRRSD / NULL / 2010-04-16 00:00:00.000 / NULL / classdates
Now I've got a LINQ command to pull only the rows where the type is classdates from this table:
Dim dbGetRegisterDates As New dcConfigDataContext
Dim getDates = ...
Hi, what is a good way to write unit tests with a LINQ to SQL DAL?
Currently I am doing some database testing and need to create helper methods that access the database, but I don't want those methods in my main repo's.
So what I have is two copies of the DAL, one in my main project and one in the Test project. Is it easier to manage ...
In .NET 4 and multicore environment, does the linq to sql datacontext object take advantage of the new parallels if we use DataLoadOptions.LoadWith?
EDIT
I know linq to sql does not parallelize ordinary queries. What I want to know is when we specify DataLoadOption.LoadWith, does it use parallelization to perform the match between each...
public IEnumerable<T> ExecuteStoredProcedure<T>(params object[] parameters)
{
Type genericType = typeof(T);
string commandthing = genericType.Name.Replace("Result", "");
//_db is my Linq To Sql database
return _db.ExecuteQuery<T>(commandthing, parameters).AsEnumerable();
}
...
Newbie problem: I have a SQL SP with ten parameters (eight input, two output) but when I attempt to call it via LINQ from code I get the following error message:
"The best overloaded method match for 'DataClassesDataContext.ST_CR_CREATE_CASE_BASIS(string, string, string, string, System.DateTime?, string, string, string, ref int?, ref in...
Hi can someone help me convert this tsql statement into c# linq2sql?
select [series] from table group by [series] order by max([date]) desc
This is what i have so far - the list is not in correct order..
var x = from c in db.Table
orderby c.Date descending
group c by c.Series into ...