I have a Linq collection of Things, where Thing has an Amount (decimal) property.
I'm trying to do an aggregate on this for a certain subset of Things:
var total = myThings.Sum(t => t.Amount);
and that works nicely. But then I added a condition that left me with no Things in the result:
var total = myThings.Where(t => t.OtherProper...
Hi,
I had asked this question
http://stackoverflow.com/questions/2442149/adding-more-attributes-to-linq-to-sql-entity
Now, when I add Browsable attribute to generated entity in designer,it works.But,when I use the MetaDataType approach,and add Browsable attribute in partial class,it does not work
"I added a MetaDataType class, and ad...
I have a form that returns me a List of FlatSessie objects
in my edit view I edit a few FlatSessie's and get them returned to my Post method in that List object.
In my DB I have Sessies, which I map using Automapper to FlatSessie's and back
now I can not get linq to make the update to the DB for me.
the code:
[HttpPost]
pub...
The help file that came with Dynamic Linq in the CSharpSamples.zip does not show any examples of using contains or like.
Are there any simple workarounds for doing this? i.e where (col like @col) doesn't work.
...
In my repository layer I am mapping Linq-to-Sql objects to my application domain objects. The code below shows how I am doing this for a complex object, product:
public IQueryable<Product> Products {
get
{
var result = from p in _db.Products
let images = GetProductImages(p.Pr...
Hey
I'm trying to do a nested lambda expression like to following:
textLocalizationTable.Where(
z => z.SpokenLanguage.Any(
x => x.FromCulture == "en-GB")
).ToList();
but i get the error:
Member access 'System.String FromCulture' of
'DomainModel.Entities.SpokenLanguage' not legal on type
'System.Data.Linq.EntitySet`1[DomainM...
I have the a simple LinqToSQL statement that is not working. Something Like this:
List<MyClass> myList = _ctx.DBList
.Where(x => x.AGuidID == paramID)
.Where(x => x.BBoolVal == false)
.ToList();
I look at _ctx.DBList in the debugger and the second item fits both parameters.
Is there a way I can dig into this more ...
I have a column of type Bit (called BBoolVal in this example).
I have a LinqToSQL Statement Like this:
var query = List<MyClass> myList = _ctx.DBList
.Where(x => x.AGuidID == paramID)
.Where(x => x.BBoolVal == false);
When I look at the sql it ends up like this (I added the spacing and changed the names):...
I'm encountering a hang when the program tries to access the fruit database. I've already enabled network access MSDTC on both my development computer and the SQL Server server.
Code:
(pardon the code coloring...SO's misinterpreting my VB .NET)
Using ts As New TransactionScope
Dim fruit As New FruitDataContext
D...
Hi...
I've got an entity object - Customer, with a property called VATRate.
This VATRate is in the form of a decimal (0.25). I wanted to be able to enter a percentage value, and save it in the correct decimal value in the database, so I made this custom property:
partial class Customer{
public decimal VatPercent {
get{ .....
I have created myself a typed repository interface IRepository that has methods defined such as Save, Delete, FindById, FindAll etc I then created a concrete class Repository that implements all these methods using:
_context.GetTable(typeof(TEntity).
I can than create my CustomerRepository like so:
public class CustomerRepository : Re...
I ended up with this horrible code below, I can't get a better result now.
What is a better way of doing that?
It's about this part of my database:
EDIT
A Patient has a Subscription to multiple MonitoringObjects. Target records refer to these Subscriptions. I want to retrieve the target records with the newest date per Subscription ...
Is it possible to wrap some "external" API code AND a LINQ data context into a transaction? In my case, I want to wrap the ASP.NET 2.0 Membership API calls AND my own LINQ operations into a transaction.
...
At random times, twice in the past two weeks, the we application will start to error and not work until I recycle the app pool in IIS.
The specific error and stacktrace are:
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidCastException: Unable to cast object of typ...
OK, This is starting to get mildly irritating. I tried to implement Twitter style paging using ASP.NET MVC and JQuery. My problem is that when not using
Request.IsAjaxRequest() (for users with javascript turned off) it works fine, obviously posting back the whole page. When I run the code for Request.IsAjaxRequest(), it skips entries...
I'm using ASP.NET MVC RC2. I have a set of classes that were auto-generated "Linq-to-SQL Classes", where each class models a table in my database. I have some default "edit" views that use the neat-o Html.TextBoxFor helper extension to render HTML input fields for the columns in a table.
However, I notice that there is no MAXLENGTH attr...
I have a list (that comes to my middleware app from the client) that I need to put in my database. Some items in the list may already be in the db (just need an update). Others are new inserts.
This turns out to be much harder than I thought I would be. Here is my code to do that. I am hoping there is a better way:
public void Inse...
In my 2nd ASP.NET MVC project I'm facing a very weird problem: when I call the SubmitChanges method of the DataContext class, nothing updates in the database. It's weird because everything works fine with my first project.
I'm using a remote database created in Sql Server Management Studio, I tried doing some queries there and in Visual...
the ToSelectList method I have:
public static IList<SelectListItem> ToSelectList<T>(this IEnumerable<T> itemsToMap, Func<T, string> textProperty, Func<T, string> valueProperty, Predicate<T> isSelected)
{
var result = new List<SelectListItem>();
foreach (var item in itemsToMap)
{
result.Add(new SelectListItem
...
Hello.
I have a short question. Im my current project I'm using LINQ-to-SQl. That is the best way to determine if table has record with specific ID?
Thanks in advance.
...