Search Results

Search found 19804 results on 793 pages for 'linq to xml'.

Page 14/793 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • LINQ-to-SQL class doesn't implement INotifyPropertyChanging & INotifyPropertyChanged if pulling from

    - by Traples
    I modified my data source in my LINQ-to-SQL class (by the old delete and drag back in method), and was surprised to see the INotifyPropertyChanging & INotifyPropertyChanged interfaces no longer implemented in the generated classes (MyDb.designer.cs). The methods for the individual fields went from looking like this... [Column(Storage="_Size", DbType="NVarChar(100)")] public string Size { get { return this._Size; } set { if ((this._Size != value)) { this.OnSizeChanging(value); this.SendPropertyChanging(); this._Size = value; this.SendPropertyChanged("Size"); this.OnSizeChanged(); } } } To looking like this... [Column(Storage="_Size", DbType="NVarChar(100)")] public string Size { get { return this._Size; } set { if ((this._Size != value)) { this._Size = value; } } } Any ideas on why this happens and how it will affect my application?

    Read the article

  • LINQ-to-SQL: Searching against a CSV

    - by Peter Bridger
    I'm using LINQtoSQL and I want to return a list of matching records for a CSV contains a list of IDs to match. The following code is my starting point, having turned a CSV string in a string array, then into a generic list (which I thought LINQ would like) - but it doesn't: Error Error 22 Operator '==' cannot be applied to operands of type 'int' and 'System.Collections.Generic.List<int>' C:\Documents and Settings\....\Search.cs 41 42 C:\...\ Code DataContext db = new DataContext(); List<int> geographyList = new List<int>( Convert.ToInt32(geography.Split(',')) ); var geographyMatches = from cg in db.ContactGeographies where cg.GeographyId == geographyList select new { cg.ContactId }; Where do I go from here?

    Read the article

  • Combining 2 Linq queries into 1

    - by Mike Fielden
    Given the following information, how can I combine these 2 linq queries into 1. Having a bit of trouble with the join statement. 'projectDetails' is just a list of ProjectDetails ProjectDetails (1 to many) PCardAuthorizations ProjectDetails (1 to many) ExpenditureDetails Notice I am grouping by the same information and selecting the same type of information var pCardAccount = from c in PCardAuthorizations where projectDetails.Contains(c.ProjectDetail) && c.RequestStatusId == 2 group c by new { c.ProjectDetail, c.ProgramFund } into g select new { Key = g.Key, Sum = g.Sum(x => x.Amount) }; var expenditures = from d in ExpenditureDetails where projectDetails.Contains(d.ProjectDetails) && d.Expenditures.ExpenditureTypeEnum == 0 group d by new { d.ProjectDetails, d.ProgramFunds } into g select new { Key = g.Key, Sum = g.Sum(y => y.ExpenditureAmounts.FirstOrDefault(a => a.IsCurrent && !a.RequiresAudit).CommittedMonthlyRecords.ProjectedEac) };

    Read the article

  • Dynamic where clause in LINQ - with column names available at runtime

    - by sandesh247
    Disclaimer: I've solved the problem using Expressions from System.Linq.Expressions, but I'm still looking for a better/easier way. Consider the following situation : var query = from c in db.Customers where (c.ContactFirstName.Contains("BlackListed") || c.ContactLastName.Contains("BlackListed") || c.Address.Contains("BlackListed")) select c; The columns/attributes that need to be checked against the blacklisted term are only available to me at runtime. How do I generate this dynamic where clause? An additional complication is that the Queryable collection (db.Customers above) is typed to a Queryable of the base class of 'Customer' (say 'Person'), and therefore writing c.Address as above is not an option.

    Read the article

  • LINQ 2 SQL Insert Error(with Guids)

    - by Refracted Paladin
    I have the below LINQ method that I use to create the empty EmploymentPLan. After that I simply UPDATE. For some reason this works perfectly for myself but for my users they are getting the following error -- The target table 'dbo.tblEmploymentPrevocServices' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause. This application is a WinForm app that connects to a local SQL 2005 Express database that is a part of a Merge Replication topology. This is an INTERNAL App only installed through ClickOnce. public static Guid InsertEmptyEmploymentPlan(int planID, string user) { using (var context = MatrixDataContext.Create()) { var empPlan = new tblEmploymentQuestionnaire { PlanID = planID, InsertDate = DateTime.Now, InsertUser = user, tblEmploymentJobDevelopmetService = new tblEmploymentJobDevelopmetService(), tblEmploymentPrevocService = new tblEmploymentPrevocService() }; context.tblEmploymentQuestionnaires.InsertOnSubmit(empPlan); context.SubmitChanges(); return empPlan.EmploymentQuestionnaireID; } }

    Read the article

  • LINQ 2 SQL Insert Error

    - by Refracted Paladin
    I have the below LINQ method that I use to create the empty EmploymentPLan. After that I simply UPDATE. For some reason this works perfectly for myself but for my users they are getting the following error -- The target table 'dbo.tblEmploymentPrevocServices' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause. This application is a WinForm app that connects to a local SQL 2005 Express database. public static Guid InsertEmptyEmploymentPlan(int planID, string user) { using (var context = MatrixDataContext.Create()) { var empPlan = new tblEmploymentQuestionnaire { PlanID = planID, InsertDate = DateTime.Now, InsertUser = user, tblEmploymentJobDevelopmetService = new tblEmploymentJobDevelopmetService(), tblEmploymentPrevocService = new tblEmploymentPrevocService() }; context.tblEmploymentQuestionnaires.InsertOnSubmit(empPlan); context.SubmitChanges(); return empPlan.EmploymentQuestionnaireID; } }

    Read the article

  • Mixing LINQ to SQL with properties of objects in a generic list

    - by BPotocki
    I am trying to accomplish something like this query: var query = from a in DatabaseTable where listOfObjects.Any(x => x.Id == a.Id) select a; Basically, I want to filter the results where a.Id equals a property of one of the objects in the generic list "listOfObjects". I'm getting the error "Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator." Any ideas on how to filter this in an easily readable way using "contains" or another method? Thanks in advance.

    Read the article

  • How to assign one object to another in Linq c# without making new

    - by LLL
    I m facing issue in assiging one object to another in linq sql. In this example Func<result, result> make = q => new result { Id = q.Id, lName = q.lName, GroupId = q.GroupId, Age = (from tags in q.age where tags.Del == null && tags.lId == q.Id select age).ToEntitySet(), }; p = (from q in dc.results where q.Id == Id.Value select make(q)).First(); i am making new and assigning the object, but i dont want to do this, it will cause propblem in insertion. so i want to assign without making new, how is it possible?

    Read the article

  • LINQ Lycanthropy: Transformations into LINQ

    LINQ is one of the few technologies that you can start to use without a lot of preliminary learning. Also, it lends itself to learning by trying out examples. With Michael Sorens' help, you can watch as your conventional C# code changes to ravenous LINQ before your very eyes. Join SQL Backup’s 35,000+ customers to compress and strengthen your backups "SQL Backup will be a REAL boost to any DBA lucky enough to use it." Jonathan Allen. Download a free trial now.

    Read the article

  • XML to be validated against multiple xsd schemas

    - by Michael Rusch
    I'm writing the xsd and the code to validate, so I have great control here. I would like to have an upload facility that adds stuff to my application based on an xml file. One part of the xml file should be validated against different schemas based on one of the values in the other part of it. Here's an example to illustrate: <foo> <name>Harold</name> <bar>Alpha</bar> <baz>Mercury</baz> <!-- ... more general info that applies to all foos ... --> <bar-config> <!-- the content here is specific to the bar named "Alpha" --> </bar-config> <baz-config> <!-- the content here is specific to the baz named "Mercury" --> </baz> </foo> In this case, there is some controlled vocabulary for the content of <bar>, and I can handle that part just fine. Then, based on the bar value, the appropriate xml schema should be used to validate the content of bar-config. Similarly for baz and baz-config. The code doing the parsing/validation is written in Java. Not sure how language-dependent the solution will be. Ideally, the solution would permit the xml author to declare the appropriate schema locations and what-not so that s/he could get the xml validated on the fly in a sufficiently smart editor. Also, the possible values for <bar> and <baz> are orthogonal, so I don't want to do this by extension for every possible bar/baz combo. What I mean is, if there are 24 possible bar values/schemas and 8 possible baz values/schemas, I want to be able to write 1 + 24 + 8 = 33 total schemas, instead of 1 * 24 * 8 = 192 total schemas. Also, I'd prefer to NOT break out the bar-config and baz-config into separate xml files if possible. I realize that might make all the problems much easier, as each xml file would have a single schema, but I'm trying to see if there is a good single-xml-file solution.

    Read the article

  • Binding XML in Sliverlight without Nominal Classes

    - by AnthonyWJones
    Lets say I have a simple chunck of XML:- <root> <item forename="Fred" surname="Flintstone" /> <item forename="Barney" surname="Rubble" /> </root> Having fetched this XML in Silverlight I would like to bind it with xaml of this ilke:- <ListBox x:Name="ItemList" Style="{StaticResource Items}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBox Text="{Binding Forename}" /> <TextBox Text="{Binding Surname}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Now I can bind simply enough with LINQ to XML and a nominal class:- public class Person { public string Forename {get; set;} public string Surname {get; set;} } So here is the question, can it be done without this class? IOW coupling between the Sliverlight code and the input XML is limited to the XAML only, other source code is agnostic to the set of attributes on the item element. Edit: The use of XSD is suggested but ultimately it amounts the same thing. XSD-Generated class. Edit: An anonymous class doesn't work, Silverlight can't bind them. Edit: This needs to be two way, the user needs to be able to edit the values and these value end up in the XML. (Changed original TextBlock to TextBox in sample above).

    Read the article

  • c# XML add an XML node as a child to a particular other node

    - by kacalapy
    I have an XML doc with a structure like this: <Book> <Title title="Door Three"/> <Author name ="Patrick"/> </Book> <Book> <Title title="Light"/> <Author name ="Roger"/> </Book> I want to be able to melodramatically add XML nodes to this XML in a particular place. Lets say I wanted to add a Link node as a child to the author node where the name is Roger. I think it's best if the function containing this logic is passed a param for the name to add an XML node under, please advise and what's the code I need to add XML nodes to a certain place in the XML? Now I am using .AppendChild() method but it doesn't allow for me to specify a parent node to add under...

    Read the article

  • Fast search in XMl files in .NET (or How to index XML files)

    - by codymanix
    I have to implement a search feature which is able to quickly perform arbitrary complex queries to XML-data. If the user makes a query, all XML files must be searched to find possible matches. The users will have lots of XML-Files (a few 10000 or more) which are typically a few kilobytes in size. All the XML-files have almost the same structure. I already benchmarked XPath, it is too slow for my needs. How can it be done most efficiently? Is is possible to create indexes for the contents of the XML files (preserving content semantics, not just plain fulltext search)? Will it be useful to put the XML data into an (embedded) SQL database and do the queries with SQL? What other possibilities do I have?

    Read the article

  • Linq to xml, retreaving generic interface-based list

    - by Rita
    I have an xml document that looks like this <Elements> <Element> <DisplayName /> <Type /> </Element> </Elements> I have an interface, interface IElement { string DisplayName {get;} } and a couple of derived classes: public class AElement: IElement public class BElement: IElement What I want to do, is to write the most efficient query to iterate through the xml and create a list of IElement, containing AElement or BElement, based on the 'Type' property in the xml. So far I have this: IEnumerable<AElement> elements = from xmlElement in XElement.Load(path).Elements("Element") where xmlElement.Element("type").Value == "AElement" select new AElement(xmlElement.Element("DisplayName").Value); return elements.Cast<IElement>().ToList(); But this is only for AElement, is there a way to add BElement in the same query, and also make it generic IEnumerable? Or would I have to run this query once for each derived type?

    Read the article

  • data is not getting ordered by date

    - by raging_boner
    Can't get list sorted by date. How to show data ordered by date? XDocument doc = XDocument.Load(Server.MapPath("file.xml")); IEnumerable<XElement> items = from item in doc.Descendants("item") orderby Convert.ToDateTime(item.Attribute("lastChanges").Value) descending where item.Attribute("x").Value == 1 select item; Repeater1.DataSource = items; Repeater1.DataBind(); Xml file looks like this: <root> <items> <item id="1" lastChanges="15-05-2010" x="0" /> <item id="2" lastChanges="16-05-2010" x="1" /> <item id="3" lastChanges="17-05-2010" x="1" /> </items> </root>

    Read the article

  • LINQ to XML query attributes

    - by kb
    Hi using LINQ to XML, this is a sample of my XML <shows> <Show Code="456" Name="My Event Name"> <Event Code="2453" VenueCode="39" Date="2010-04-13 10:30:00" /> <Event Code="2454" VenueCode="39" Date="2010-04-13 13:30:00" /> <Event Code="2455" VenueCode="39" Date="2010-04-14 10:30:00" /> <Event Code="2456" VenueCode="39" Date="2010-04-14 13:30:00" /> <Event Code="2457" VenueCode="39" Date="2010-04-15 10:30:00" /> </Show> <Show... /> <Show... /> </shows> How do I return a list of the Dates for a specfic show? I am passing the show code ("456") in the querystring and want all the dates/times returned as a list. This is the code i have so far: XDocument xDoc = XDocument.Load("path to xml"); var feeds = from feed in xDoc.Descendants("Show") where feed.Attribute("Code").Equals("456") select new { EventDate = feed.Attribute("Date").Value }; foreach(var feed in feeds) { Response.Write(feed.EventDate + "<br />"); } But i get no results returned

    Read the article

  • [Linq to SQL] Multiple foreign keys to the same table

    - by cdonner
    I have a reference table with all sorts of controlled value lookup data for gender, address type, contact type, etc. Many tables have multiple foreign keys to this reference table I also have many-to-many association tables that have two foreign keys to the same table. Unfortunately, when these tables are pulled into a Linq model and the DBML is generated, SQLMetal does not look at the names of the foreign key columns, or the names of the constraints, but only at the target table. So I end up with members called Reference1, Reference2, ... not very maintenance-friendly. Example: <Association Name="tb_reference_tb_account" Member="tb_reference" <====== ThisKey="shipping_preference_type_id" OtherKey="id" Type="tb_reference" IsForeignKey="true" /> <Association Name="tb_reference_tb_account1" Member="tb_reference1" <====== ThisKey="status_type_id" OtherKey="id" Type="tb_reference" IsForeignKey="true" /> I can go into the DBML and manually change the member names, of course, but this would mean I can no longer round-trip my database schema. This is not an option at the current stage of the model, which is still evolving. Splitting the reference table into n individual tables is also not desirable. I can probably write a script that runs against the XML after each generation and replaces the member name with something derived from ThisKey (since I adhere to a naming convention for these types of keys). Has anybody found a better solution to this problem?

    Read the article

  • ASP.Net Entity Framework Repository & Linq

    - by Chris Klepeis
    My scenario: This is an ASP.NET 4.0 web app programmed via C# I implement a repository pattern. My repositorys all share the same ObjectContext, which is stored in httpContext.Items. Each repository creates a new ObjectSet of type E. Heres some code from my repository: public class Repository<E> : IRepository<E>, IDisposable where E : class { private DataModelContainer _context = ContextHelper<DataModelContainer>.GetCurrentContext(); private IObjectSet<E> _objectSet; private IObjectSet<E> objectSet { get { if (_objectSet == null) { _objectSet = this._context.CreateObjectSet<E>(); } return _objectSet; } } public IQueryable<E> GetQuery() { return objectSet; } Lets say I have 2 repositorys, 1 for states and 1 for countrys and want to create a linq query against both. Note that I use POCO classes with the entity framework. State and Country are 2 of these POCO classes. Repository stateRepo = new Repository<State>(); Repository countryRepo = new Repository<Country>(); IEnumerable<State> states = (from s in _stateRepo.GetQuery() join c in _countryRepo.GetQuery() on s.countryID equals c.countryID select s).ToList(); Debug.WriteLine(states.First().Country.country) essentially, I want to retrieve the state and the related country entity. The query only returns the state data... and I get a null argument exception on the Debug.WriteLine LazyLoading is disabled in my .edmx... thats the way I want it.

    Read the article

  • LINQ(2 SQL) Insert Multiple Tables Question

    - by Refracted Paladin
    I have 3 tables. A primary EmploymentPlan table with PK GUID EmploymentPlanID and 2 FK's GUID PrevocServicesID & GUID JobDevelopmentServicesID. There are of course other fields, almost exclusively varchar(). Then the 2 secondary tables with the corresponding PK to the primary's FK's. I am trying to write the LINQ INSERT Method and am struggling with the creation of the keys. Say I have a method like below. Is that correct? Will that even work? Should I have seperate methods for each? Also, when INSERTING I didn't think I needed to provide the PK for a table. It is auto-generated, no? Thanks, public static void InsertEmploymentPlan(int planID, Guid employmentQuestionnaireID, string user, bool communityJob, bool jobDevelopmentServices, bool prevocServices, bool transitionedPrevocIntegrated, bool empServiceMatchPref) { using (var context = MatrixDataContext.Create()) { var empPrevocID = Guid.NewGuid(); var prevocPlan = new tblEmploymentPrevocService { EmploymentPrevocID = empPrevocID }; context.tblEmploymentPrevocServices.InsertOnSubmit(prevocPlan); var empJobDevID = Guid.NewGuid(); var jobDevPlan = new tblEmploymentJobDevelopmetService() { JobDevelopmentServicesID = empJobDevID }; context.tblEmploymentJobDevelopmetServices.InsertOnSubmit(jobDevPlan); var empPlan = new tblEmploymentQuestionnaire { CommunityJob = communityJob, EmploymentQuestionnaireID = Guid.NewGuid(), InsertDate = DateTime.Now, InsertUser = user, JobDevelopmentServices = jobDevelopmentServices, JobDevelopmentServicesID =empJobDevID, PrevocServices = prevocServices, PrevocServicesID =empPrevocID, TransitionedPrevocToIntegrated =transitionedPrevocIntegrated, EmploymentServiceMatchPref = empServiceMatchPref }; context.tblEmploymentQuestionnaires.InsertOnSubmit(empPlan); context.SubmitChanges(); } } I understand I can use more then 1 InsertOnSubmit, See SO ? HERE, I just don't understand how that would apply to my situation and the PK/FK creation.

    Read the article

  • Linq - Orderby not ordering

    - by Billy Logan
    Hello everyone, I have a linq query that for whatever reason is not coming back ordered as i would expect it to. Can anyone point me in the right direction as to why and what i am doing wrong? Code is as follows: List<TBLDESIGNER> designer = null; using (SOAE strikeOffContext = new SOAE()) { //Invoke the query designer = AdminDelegates.selectDesignerDesigns.Invoke(strikeOffContext).ByActive(active).ByAdmin(admin).ToList(); } Delegate: public static Func<SOAE, IQueryable<TBLDESIGNER>> selectDesignerDesigns = CompiledQuery.Compile<SOAE, IQueryable<TBLDESIGNER>>( (designer) => from c in designer.TBLDESIGNER.Include("TBLDESIGN") orderby c.FIRST_NAME ascending select c); Filter ByActive: public static IQueryable<TBLDESIGNER> ByActive(this IQueryable<TBLDESIGNER> qry, bool active) { //Return the filtered IQueryable object return from c in qry where c.ACTIVE == active select c; } Filter ByAdmin: public static IQueryable<TBLDESIGNER> ByAdmin(this IQueryable<TBLDESIGNER> qry, bool admin) { //Return the filtered IQueryable object return from c in qry where c.SITE_ADMIN == admin select c; } Wondering if the filtering has anything to do with it?? Thanks in advance, Billy

    Read the article

  • Linq to NHibernate wrapper issue using where statement

    - by Jacob
    I'am using wrapper to get some data from table users IQueryable<StarGuestWrapper> WhereQuery = session.Linq<User>().Where(u => u.HomeClub.Id == clubId && u.IsActive).Select( u => new StarGuestWrapper() { FullName = u.Name + " " + u.LastName, LoginTime = DateTime.Now, MonthsAsMember = 2, StarRating = 1, UserPicture = u.Photo.PhotoData, InstructorFullName = "Someone Xyz", TalkInteractionDuringSession = true, GoalInteractionDuringSession = false }); I use this without a problem as a IQueryable so I can do useful things before actually running the query. Like : WhereQuery.Skip(startRowIndex).Take(maximumRows).ToList(); and so on. The problem occurs using 'where' statement on query. For example: WhereQuery.Where(s => s.StarRating == 1) will throw an exception in runtime that 'StarRating' doesn't exist in User table - of course it doesn't it's a wrappers property. I will work if I materialize query by WhereQuery.AsEnumerable().Where(s => s.StarRating == 1) but then it loses all the sens of using IQueryable and I don't want to do this. What is strange and interesting that not all properties from wrapper throw error, all the bool values can be used in where statement. Example : WhereQuery.Where(s => s.TalkInteractionDuringSession) It works in EntityFramework , why do I get this error in NHibernate and how to get it working the way I want it to ?

    Read the article

  • LINQ to SQL - Left Outer Join with multiple join conditions

    - by dan
    I have the following SQL which I am trying to translate to LINQ: SELECT f.value FROM period as p LEFT OUTER JOIN facts AS f ON p.id = f.periodid AND f.otherid = 17 WHERE p.companyid = 100 I have seen the typical implementation of the left outer join (ie. into x from y in x.DefaultIfEmpty() etc.) but am unsure how to introduce the other join condition ('AND f.otherid = 17') EDIT Why is the 'AND f.otherid = 17' condition part of the JOIN instead of in the WHERE clause? Because f may not exist for some rows and I still want these rows to be included. If the condition is applied in the WHERE clause, after the JOIN - then I don't get the behaviour I want. Unfortunately this: from p in context.Periods join f in context.Facts on p.id equals f.periodid into fg from fgi in fg.DefaultIfEmpty() where p.companyid == 100 && fgi.otherid == 17 select f.value seems to be equivalent to this: SELECT f.value FROM period as p LEFT OUTER JOIN facts AS f ON p.id = f.periodid WHERE p.companyid = 100 && AND f.otherid = 17 which is not quite what I'm after.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >