Hello, I'm a newbie to StackOverflow so please be kind ;)
I'm using Entity Framework in Visual Studio 2010 Beta 2 (.NET framework 4.0 Beta 2). I have created an entity framework .edmx model from my database and I have a handful of many-to-many relationships.
A trivial example of my database schema is
Roles (ID, Name, Active)
Members (...
I'm wondering what the best approach to adding an artificial row to an anonymous linq result set would be.
I have a linq statement which uses "select new" to form the data required. Each record comes back as an anonymous object with ID and Name properties. However, I require that the first row of the data becomes an object with ID = NUL...
Hello,
Let's say I have two tables (Address and Phone) in sql which have one-to-one relationship. I have created corresponding linq to sql classes and changed the association to OneToOne
I want to retrieve both objects by filtering child object. e.g I have the following query which works fine:
var n = db.Addresses.Where(t => t.Phone.N...
I need to make a LINQ query against GridView filled with SqlDataSource - to create a Dictionary from rows.
So I have:
<asp:GridView runat="server" ID="gridCurrency" DataSourceID="sourceCurrency" OnDataBound="gridCurrency_DataBound"
<asp:SqlDataSource runat="server" ID="sourceCurrency" ConnectionString="<%$ ConnectionStrings:MyConnStr %...
Suppose I have written a class Customer which has it attributes as Name, Age, designation etc. And I have a table also as customer with the same attributes.
Now I dont want to use the designer provided that generates the entity classes for me.
Is it possible for me to map the Customer.cs to the table customer while using LINQ to SQL as...
If I have input string in C#, how can I do series of Regex / linq operations on it to do Regex match on one piece of string and then another Regex on all pieces of string which are not matched by 1st Regex.
In other words, for input string:
<!-- Lorem ipsum dolor sit amet, consectetur adipiscing elit -->
<!-- The quick brown fox jump...
I'm trying to create an XML file using C# and Linq to XML, but am having problems with the nant namespace.
var myXElement = new XElement("project", new XAttribute("name", "MySystemName"), new XAttribute("default", "myNAntTargetName"), new XAttribute("xmlns", "http://nant.sf.net/schemas/nant.xsd"));
myXElement.Save("c:\foo.xml");
Beca...
Right now I can do this with Linq to SQL
response.write(car.models(0).makes(2).model.car.ID)
of course you wouldn't actually do exactly this but I'm showing how I can go up and down the chain of relationships
Now I want to do the same with simple Class Objects that aren't populated by data from some other source but I can't go "backwa...
I am working with Moles and mocking a System.Data.Linq.Table.
I got it constructing fine, but when I use it, it wants IQueryable.Provider to be mocked (moled) as well.
I just want it to use normal Linq To Objects. Any idea what that would be?
Here is the syntax I can use:
MTable<User> userTable = new System.Data.Linq.Moles.MTable<Us...
I'm using the following DataLoadOptions:
DataLoadOptions options = new DataLoadOptions();
options.LoadWith<Family>(f => f.FamilyLanguages);
options.LoadWith<FamilyLanguage>(fl => fl.Language);
The Family object comes back with a list of FamilyLanguages, but the FamilyLanguages have only got a LanguageID, the Language object is null.
...
I'm trying to capture Elements with a child decendent attribute == value
class Program
{
static void Main(string[] args)
{
XDocument doc = XDocument.Load(@"path to doc");
var query = from q in doc.Elements("Candidates").Elements("Candidates")
//How to filter based on descendant attribute value...
I've been using LINQ for awhile (and enjoy it), but it feels like I hit a speedbump when I run across .NET specialized collections(DataRowCollection, ControlCollection). Is there a way to use LINQ with these specialized controls, and if not do you think Microsoft will address this in the next release of the framework? Or are we left to...
Have the following Stored procedure for a search form. I use Linq and have problem to get the result of this procedure....am I in the wrong way in procedure or in linq?
You can see my linq down here too..I have tried different ways..but now i need your help :)
ALTER PROCEDURE [dbo].[SearchPostit]
(
@message varchar(1000)='',
@write...
Hi,
I have the following situation. I have a list of items which have an "Id". I have to search for an item with a specific id, modify its values and maintain the order of the collection. What would be the best way to do that?
var collection = <some_linq_query>
collection.Where(i=>i.Id=someId).FirstOrDefault().Property = "bla";
// no...
Let's say I have nodes like so:
<Params>
<Param val="C" />
<Param val="D" />
<Param val="A" />
<Param val="B" />
<Params>
If I select the Descendants of Params is the order always preserved? I want C to always be first when I iterate through the ordered list that I'll be dropping these into. Or do I need to come up with a differe...
I am currently working on a project where i need to show row data in gridview columns, so for example, if my data is in the following form.
Username Jack
Phone 2222222
Email [email protected]
and i want to show this data as per columns in gridview as below
Username Phone Email
jack 2222222 ...
Hi All
Linq noob here.
I have IList<Product> ApplicableProducts and a IList<Product> CurrentProducts.
I need to return a new IList<Product> of all CurrentProducts that exist in Applicable products.
I understand I need to be working with .Contains and .Any but getting a little lost.
Any tips appreciated
...
Hi All,
How can I get the name of the first method called from an expression in C#? Something like the fictional MethodUtils.NameFromExpression() below:
Expression<Action<string>> expr = s => s.Trim();
Assert.AreEqual("Trim", MethodUtils.NameFromExpression(expr));
Ideally any util method would be written/overloaded in such a way tha...
I have the following dictionary:
Dictionary<long, ChangeLogProcess> _changeLogProcesses =
new Dictionary<long, ChangeLogProcess>();
I have a method that attempts to get the next changelogprocess in the dictionary of a particular status (If there are no items of a particular status it returns null):
var changeLogProcesses =
...
Hi,
I'm trying db4o and i'm having bad performance when using linq to db4o. (using 7.12)
Here is my configuration :
var configuration = Db4oFactory.Configure();
configuration.ObjectClass(typeof(MyTest)).ObjectField("MyInt").Indexed(true);
Here is the object i'm trying to save :
public class MyTest
{
public int M...