I have a problem to decide which layer in my system should create DataContext. I have read a book, saying that if do not pass the same DataContext object for all the
database updates, it will sometimes get an exception thrown from the DataContext. That's why i initially create new instance of DataContext in business layer, and pass it in...
Running .net 2008, asp.net, Linq to sql, sql server 2008 express
Foo f = db.Foo.First(x => x.ID == id);
f.IsValid = true;
db.SubmitChanges();
I have a very basic table, which has several fields, and no FK constraints. None of the data saves when I call .SubmitChanges(), but no error is thrown. Any ideas?
Not using any explicit tran...
Say I have an entity Customer which has relationship with city, order etc. Now when I am adding a customer object, should I assign customer.cityid, or customer.city? From the form I get cityid from a dropdown, so to assign the city object, I will have to make a query using id selected.
...
I have a MVC page which allows creation and editing of a subcontract. When the user has to select a company for the subcontract, I would like for them to have the option to create a new company. I've made a jQuery pop-up with the company fields, but I don't know how to then save this information to the company table. I would also like...
hi,
i am really lost at this, i am able to get the jason result and here is it from firebug console
{"d":[{"__type":"Table1:#","id":1,"name":"asd","Table2s":[{"__type":"Table2:#","id":2,"family":"dfdfd","fid":1}]},{"__type":"Table1:#","id":2,"name":"wewe","Table2s":[{"__type":"Table2:#","id":1,"family":"fff","fid":2}]}]}
now my quest...
I'm very fond of Linq to SQL and the programming model it encourages. I think that in many cases when you are in control of both the database schema and the code it is not worth the effort to have different relational and object models for the data. Working with Linq to SQL makes it simple to have type safe data access from .NET, using t...
Learning C# and learing Linq now. have lots of qestions about it. Basically I need a step by step tutorial.
I suppose the dbml file is the configuration file of the database. I double click it and VS will open it with kind of design diagram. I can create/delete/modify table here? I can use add new item to add the Linq to SQL Classes to...
Customer wants to move from SQL server to Sybase database. Don't know if LINQ can still be here? change is big?
...
SQL query:
SELECT ArticleCategories.Title AS Category, Articles.Title, Articles.[Content], Articles.Date
FROM ArticleCategories INNER JOIN
Articles ON ArticleCategories.CategoryID = Articles.CategoryID
Object repository:
public class ArticleDisplay
{
public int CategoryID;
public str...
Hi all
There seems to be an issue with the default model binder when binding to an EntitySet causes the EntitySet to be empty.
The problem is described here and here:
Microsoft's response is:
... We have now fixed this and the fix will be included in .NET Framework 4.0. With the new behavior, if the EntitySet passed into Assign is t...
Hi there,
Kirk yesterday helped me with this problem http://stackoverflow.com/questions/2491482/linq-grouping-by-and-creating-a-formula-based-on-the-returned-results
Which works perfectly if I am using a custom list to group against.
My Linq query is returning 4 fields int ItemID,int ItemTypeID,double ItemPrice,int ProcessedType
Le...
I am new to the whole unit testing stuff, so please excuse my lack of experience. I've read a lot of materials saying that no test should depend on others to do, i.e unit tests be completely independent form each other. Can you really do that in reality? I am having the following example: I have a few entity classes depending on each oth...
I've got exception about convert NULL to Int32.
I've got a table from database with nullable tinyint
[Column(Storage="_StatType", DbType="tinyint NULL")]
public StatType : int { get { _StatType; } }
(to get C# code just replace variable's type)
and after making linq select
def StartLinq = linq <#from lpi in _CfgListParIzm
whe...
Dear Linq experts,
I get an SqlDateTime overflow error (Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.) when doing an INSERT using an Linq DataContext connected to SQL Server database when I do the SubmitChanges().
When I use the debugger the date value is correct. Even if I temporary update the code to set the date ...
How to ignore blank elements in linq query
I have a linq query
var usersInDatabase =
from user in licenseUserTable
where user.FirstName == first_name &&
user.LastName == last_name
select user;
But if I get here and first_name or last_name is blank then I want to still eval...
I need get all items these have no categories
int? categoryId = null;
var items=db.Items.Where(x=>x.CategoryId==categoryId);
this code generate in where:
where CategoryId=null
instead of
where CategoryId is null
ok, when i write
var items=db.Items.Where(x=>x.CategoryId==null);
in my sql profiler it works:
where CategoryId i...
I have an ASP.NET MVC site (which uses Linq To Sql for the ORM) and a situation where a client wants a search facility against a bespoke database whereby they can choose to either do an 'AND' search (all criteria match) or an 'OR' search (any criteria match). The query is quite complex and long and I want to know if there is a simple way...
I have a table with a varbinary(max) column for an image. I have dropped the table on the LinqToSql designer and have set "Delay load" to true, since I don't want to load the actual image data.
Is it possible to just know if the column is null or not, without getting the actual data and still only doing one query from the database?
I wou...
Hi,
I am trying to write a small app to connect and manipulate some data on an SQL 2008 Express database. The database is on my local machine but I can see it on the network. I am trying to use LINQ to SQL in my app. I am trying to connect to the database so I can add database model to use with LINQ but the problem is I can not see any ...
I just started learning LINQ to SQL, and so far I'm impressed with the easy of use and good performance.
I used to think that when doing LINQ queries like
from Customer in DB.Customers where Customer.Age > 30 select Customer
LINQ gets all customers from the database ("SELECT * FROM Customers"), moves them to the Customers array and t...