Search Results

Search found 6205 results on 249 pages for 'linq to nhibernate'.

Page 90/249 | < Previous Page | 86 87 88 89 90 91 92 93 94 95 96 97  | Next Page >

  • The model item passed into the dictionary is of type 'System.Collections.Generic.Lis

    - by mazhar
    Calling Index view is giving me this very very annoying error . Can anybody tell me what to do about it Error: The model item passed into the dictionary is of type 'System.Collections.Generic.List1[MvcApplication13.Models.Groups]', but this dictionary requires a model item of type 'MvcApplication13.Helpers.PaginatedList1[MvcApplication13.Models.Groups]'. public ActionResult Index(int? page) { const int pageSize = 10; var group =from p in _db.Groups orderby p.int_GroupId select p; var paginatedGroup = group.Skip((page ?? 0) * pageSize).Take(pageSize).ToList(); return View(paginatedGroup); } View: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" % Index <h2>Index</h2> <table> <tr> <th></th> <th> int_GroupId </th> <th> vcr_GroupName </th> <th> txt_GroupDescription </th> <th> bit_Is_Deletable </th> <th> bit_Active </th> <th> int_CreatedBy </th> <th> dtm_CreatedDate </th> <th> int_ModifiedBy </th> <th> dtm_ModifiedDate </th> </tr> <% foreach (var item in Model) { %> <tr> <td> <%= Html.ActionLink("Edit", "Edit", new { id=item.int_GroupId }) %> | <%= Html.ActionLink("Details", "Details", new { id=item.int_GroupId })%> | <%= Html.ActionLink("Delete", "Delete", new { id=item.int_GroupId })%> </td> <td> <%= Html.Encode(item.int_GroupId) %> </td> <td> <%= Html.Encode(item.vcr_GroupName) %> </td> <td> <%= Html.Encode(item.txt_GroupDescription) %> </td> <td> <%= Html.Encode(item.bit_Is_Deletable) %> </td> <td> <%= Html.Encode(item.bit_Active) %> </td> <td> <%= Html.Encode(item.int_CreatedBy) %> </td> <td> <%= Html.Encode(String.Format("{0:g}", item.dtm_CreatedDate)) %> </td> <td> <%= Html.Encode(item.int_ModifiedBy) %> </td> <td> <%= Html.Encode(String.Format("{0:g}", item.dtm_ModifiedDate)) %> </td> </tr> <% } %> </table> <% if (Model.HasPreviousPage) { % <%= Html.RouteLink("<<<", "UpcomingDinners", new { page = (Model.PageIndex-1) }) % <% } % <% if (Model.HasNextPage) { % <%= Html.RouteLink("", "UpcomingDinners", new { page = (Model.PageIndex + 1) }) % <% } % <p> <%= Html.ActionLink("Create New", "Create") %> </p>

    Read the article

  • Slow Update/insert into SQL Server CE using LinqToDatasets

    - by Vaccano
    I have a mobile app that is using LinqToDatasets to update/insert into a SQL Server CE 3.5 File. My Code looks like this: // All the MyClass Updates MyTableAdapter myTableAdapter = new MyTableAdapter(); foreach (MyClassToInsert myClass in updates.MyClassChanges) { // Update the row if it is already there int result = myTableAdapter.Update(myClass.FirstColumn, myClass.SecondColumn, myClass.FirstColumn); // If the row was not there then insert it. if (result == 0) { myTableAdapter.Insert(myClass.FirstColumn, myClass.SecondColumn); } } This code is used to keep the hand held database in sync with the server database. Problem is if it is a full update (first time for example) there are a lot of updates (about 125). That makes this code (and more loops like it take a very long time (I have three such loops that take over 30 seconds each). Is there a faster or better way to do updates/inserts like this? (I did see this Codeplex Project, but I could not see how to make it work with both updates and inserts.)

    Read the article

  • Why doesn't EnumerableRowCollection<DataRow>.Select() compile like this?

    - by David Fox
    This works: from x in table.AsEnumerable() where x.Field<string>("something") == "value" select x.Field<decimal>("decimalfield"); but, this does not: from x in table.AsEnumerable() .Where(y=>y.Field<string>("something") == "value") .Select(y=>y.Field<decimal>("decimalfield")); I also tried: from x in table.AsEnumerable() .Where(y=>y.Field<string>("something") == "value") .Select(y=>new { name = y.Field<decimal>("decimalfield") }); Looking at the two overloads of the .Select() method, I thought the latter two should both return EnumerableRowCollection, but apparently I am wrong. What am I missing?

    Read the article

  • Can't set LinqDataSource InsertParameters from my code behind.

    - by Abe Miessler
    I have the following code that seems like it should set my insertParameter but everytime an insert happens it uses the default parameter. Do i need to do anything special to make this work? Codebehind: protected void SetInsertParams(object sender, LinqDataSourceInsertEventArgs e) { if (lbl_Personnel.Visible) { lds_Personnel.InsertParameters["BudgetLineTypeCode"].DefaultValue = "S"; } else if(lbl_Operating.Visible) { lds_Personnel.InsertParameters["BudgetLineTypeCode"].DefaultValue = "O"; } else if (lbl_SubContractor.Visible) { lds_Personnel.InsertParameters["BudgetLineTypeCode"].DefaultValue = "C"; } } From my aspx page: <asp:LinqDataSource ID="lds_Personnel" runat="server" OnSelecting="SetParams" ContextTypeName="nrm.FRGPproposal.FrgpropDataContext" TableName="BudgetLines" OnInserted="lds_Personnel_OnInserted" OnInserting="SetInsertParams" Where="ProposalID == @PropNumber &amp;&amp; BudgetLineTypeCode == @BudgetLineTypeCode" EnableDelete="True" EnableInsert="True" EnableUpdate="True"> <WhereParameters> <asp:SessionParameter Name="PropNumber" SessionField="PropNumber" Type="Int32" /> <asp:Parameter DefaultValue="S" Name="BudgetLineTypeCode" Type="Char" /> </WhereParameters> <InsertParameters> <asp:SessionParameter Name="ProposalID" SessionField="PropNumber" Type="Int32"/> <asp:Parameter DefaultValue="S" Name="BudgetLineTypeCode" Type="Char" /> </InsertParameters> </asp:LinqDataSource>

    Read the article

  • Repository pattern - Switch out the database and switch in XML files

    - by glasto red
    Repository pattern - Switch out the database and switch in XML files. Hello I have an asp.net MVC 2.0 project and I have followed the Repository pattern. Periodically, I am losing access to the database server so I want to have another mechanism in place (XML files) to continue developing. It is not possible to have a local version of the db unfortunately! I thought this would be relatively easy using the Repository pattern, to switch out the db repositories and switch in XML versions. However, I am having real trouble coming up with a solution. I have tried LinqToXML but then ran into problems trying to return a List of News items as the LinqToXML ToList returns Generic.List Should I be mapping the XElement list over to the News list by hand? It just seems a bit clunky compared to LinqToSQL attributes on the News class and then simply doing a Table.....ToList(); Any direction would be appreciated. Thanks

    Read the article

  • Entity Framework query not returning correctly enumerated results.

    - by SkippyFire
    I have this really strange problem where my entity framework query isn't enumerating correctly. The SQL Server table I'm using has a table with a Sku field, and the column is "distinct". It isn't a key, but it doesn't contain any duplicate values. Using actual SQL with where, distinct and group by cluases I have confirmed this. However, when I do this: // Not good foreach(var product in dc.Products) or // Not good foreach(var product in dc.Products.ToList()) or // Not good foreach(var product in dc.Products.OrderBy(p => p.Sku)) the first two objects that are returned ARE THE SAME!!! The third item was technically the second item in the table, but then the fourth item was the first row from the table again!!! The only solution I have found is to use the Distinct extension method, which shouldn't really do anything in this situation: // Good foreach(var product in dc.Products.ToList().Distinct()) Another weird thing about this is that the count of the resulting queries is the same!!! So whether or not the resulting enumerable has the correct results or duplicates, I always get the number of rows in the actual table! (No I don't have a limit clause anywhere). What could possibly cause this!?!?!?

    Read the article

  • LINQ2SQL and MS SQL 2000

    - by artvolk
    Good day! I have used LINQ2SQL with MS SQL 2005, but now I need to use it with MS SQL 2000. I have found only article on MSDN that tells about Skip() and Take() oddities on MS SQL 2000 (that's because it lacks ROW_NUMBER(), I suppose) and nothing more. Anyway, does anybody have expirience with LINQ2SQL and MS SQL 2000 combination. P.S. Just wondering: is it possible to model LINQ2SQL class on view, not a real table?

    Read the article

  • Predicate problem in ToSelectList

    - by Stefanvds
    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 { Value = valueProperty(item), Text = textProperty(item), Selected = isSelected(item) }); } return result; } when I call this method here: public static List<SelectListItem> lesgeverList(int selectedID) { NASDataContext _db = new NASDataContext(); var lesg = (from l in _db.Lesgevers where l.LG_Naam != "leeg" orderby l.LG_Naam select l).ToSelectList(m => m.LG_Naam + " " + m.LG_Vnaam, m => m.LG_ID.ToString(), m => m.LG_ID == selectedID); return lesg.ToList(); } the selectlist I get has the selectedID as selected. now, when I want to have multiple selected items, I give a list of Lesgevers public static List<SelectListItem> lesgeverList(List<Lesgever> lg) { NASDataContext _db = new NASDataContext(); var test = (from l in _db.Lesgevers where l.LG_Naam != "leeg" && lg.Contains(l) orderby l.LG_Naam, l.LG_Vnaam select l).ToList(); var lesg = (from l in _db.Lesgevers where l.LG_Naam != "leeg" orderby l.LG_Naam, l.LG_Vnaam select l).ToSelectList(m => m.LG_Naam + " " + m.LG_Vnaam, m => m.LG_ID.ToString(), m => lg.Contains(m)); return lesg.ToList(); } the var test does return the Lesgevers that i have in the lg List, in my 'var lesg', there are no selectlistitem's selected at all. where is my mistake? :) how do I fix thix?

    Read the article

  • L2E many to many query

    - by 5YrsLaterDBA
    I have four tables: Users PrivilegeGroups rdPrivileges LinkPrivilege ----------- ---------------- --------------- --------------- userId(pk) privilegeGroupId(pk) privilegeId(pk) privilegeId(pk, fk) privilegeGroupId(fk) name code privilegeGroupId(pk, fk) L2E will not create LinkPrivilege entity for me. So we only have Users, PrivilegeGroups and rdPrivileges entities. PrivilegeGroups and rdPrivileges are many to many relationship. What I need to do is retrieve all code from rdPrivileges table based on a passed in userId. How can I do it? EDIT working code: var acc = from u in db.Users from pg in db.PrivilegeGroups from p in pg.rdPrivileges where u.UserId == userId && u.PrivilegeGroups.PrivilegeGroupId == pg.PrivilegeGroupId select p.Code;

    Read the article

  • L2E for insert, update, delete

    - by 5YrsLaterDBA
    I am using .Net3.5. Just wondering my understanding about the insert, update, delete are correct when use L2E. For insert, we need two statements: context.AddObject("entityName", newRow); context.SaveChanges(); For update, we only need one statement: context.SaveChanges(); For delete, we need two statements: context.DeleteObject(deletedRow); context.SaveChanges();

    Read the article

  • L2E delete exception

    - by 5YrsLaterDBA
    I have following code to delete an user from database: try { var user = from u in db.Users where u.Username == username select u; if (user.Count() > 0) { db.DeleteObject(user.First()); db.SaveChanges(); } } but I got exception like this: at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) at System.Data.Objects.ObjectContext.SaveChanges(Boolean acceptChangesDuringSave) at System.Data.Objects.ObjectContext.SaveChanges() at MyCompany.SystemSoftware.DQMgr.User.DeleteUser(String username) in C:\workspace\SystemSoftware\SystemSoftware\src\dqm\User.cs:line 479 The Users table is referenced by few other tables. It is probably caused by the foreign key constraint?

    Read the article

  • Adding 90000 XElement to XDocument

    - by Jon
    I have a Dictionary<int, MyClass> It contains 100,000 items 10,000 items value is populated whilst 90,000 are null. I have this code: var nullitems = MyInfoCollection.Where(x => x.Value == null).ToList(); nullitems.ForEach(x => LogMissedSequenceError(x.Key + 1)); private void LogMissedSequenceError(long SequenceNumber) { DateTime recordTime = DateTime.Now; var errors = MyXDocument.Descendants("ERRORS").FirstOrDefault(); if (errors != null) { errors.Add( new XElement("ERROR", new XElement("DATETIME", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff")), new XElement("DETAIL", "No information was read for expected sequence number " + SequenceNumber), new XAttribute("TYPE", "MISSED"), new XElement("PAGEID", SequenceNumber) ) ); } } This seems to take about 2 minutes to complete. I can't seem to find where the bottleneck might be or if this timing sounds about right? Can anyone see anything to why its taking so long?

    Read the article

  • Zipping Rx IObservable with infinite number set

    - by Toni Kielo
    I have a IObservable [named rows in the sample below] from Reactive extensions framework and I want to add index numbers to each object it observes. I've tried to implement this using Zip function: rows.Zip(Enumerable.Range(1, int.MaxValue), (row, index) => new { Row = row, Index = index }) .Subscribe(a => ProcessRow(a.Row, a.Index), () => Completed()); .. but unfortunately this throws ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: disposables Am I understanding the Zip function wrong or is there a problem with my code? The Range part of the code doesn't seem to be the problem and the IObservable isn't yet receiving any events.

    Read the article

  • Validate Linq2Sql before SubmitChanges()

    - by Nick Gotch
    Can anyone tell me if/how you can validate the changes in a data context in Linq2Sql before calling SubmitChanges(). The situation I have is that I create a context, perform multiple operations and add many inserts alongside other processing tasks and then rollback if the submit fails. What I'd prefer to do is make some kind of "Validate()" call after certain tasks are done so that I can handle it before submitting the entire job.

    Read the article

  • Entity Framework Many-To-Many with additional field on Joining Table

    - by Cory G
    I have an entity context that includes three tables (see diagram here). The first is a table that contain products, the second contains recipes. The joining table has fields for IDs in both the products and recipes table as well as a 'bit' field called 'featured'. I've searched and found no example on how to insert only how to select against this type of scenario.Does anyone have any suggestions on how this can be done? Thanks in advance for any help. Cory

    Read the article

  • Calling SubmitChanges on DataContext does not update database.

    - by drasto
    In C# ASP.NET MVC application I use Link to SQL to provide data for my application. I have got simple database schema like this: In my controller class I reference this data context called Model (as you can see on the right side of picture in properties) like this: private Model model = new Model(); I've got a table (List) of Series rendered on my page. It renders properly and I was able to add delete functionality to delete Series like this: public ActionResult Delete(int id) { model.Series.DeleteOnSubmit(model.Series.SingleOrDefault(s => s.ID == id)); model.SubmitChanges(); return RedirectToAction("Index"); } Where appropriate action link looks like this: <%: Html.ActionLink("Delete", "Delete", new { id=item.ID })%> Also create (implemented in similar way) works fine. However edit does not work. My edit looks like this: public ActionResult Edit(int id) { return View(model.Series.SingleOrDefault(s => s.ID == id)); } [HttpPost] public ActionResult Edit(Series series) { if (ModelState.IsValid) { UpdateModel(series); series.Title = series.Title + " some string to ensure title has changed"; model.SubmitChanges(); return RedirectToAction("Index"); } I have controlled that my database has a primary key set up correctly. I debugged my application and found out that everything works as expected until the line with model.SubmitChanges();. This command does not apply the changes of Title property(or any other) against the database. Please help.

    Read the article

  • Traverse list to add elements, C#.

    - by Addie
    I have a list of objects. Each object has an integer quantity and a DateTime variable which contains a month and year value. I'd like to traverse the list and pad the list by adding missing months (with quantity 0) so that all consecutive months are represented in the list. What would be the best way to accomplish this? Example: Original List { Jan10, 3 }, { Feb10, 4 }, { Apr10, 2 }, { May10, 2 }, { Aug10, 3 }, { Sep10, -3 }, { Oct10, 6 }, { Nov10, 3 }, { Dec10, 7 }, { Feb11, 3 } New List { Jan10, 3 }, { Feb10, 4 }, {Mar10, 0}, { Apr10, 2 }, { May10, 2 }, { Jun10, 0 }, { Jul10, 0 } { Aug10, 3 }, { Sep10, -3 }, { Oct10, 6 }, { Nov10, 3 }, { Dec10, 7 }, { Jan11, 0 }, { Feb11, 3 }

    Read the article

  • Case-Insensitive String Comparison not working in C#?

    - by SB2055
    Based on the answer to this question: C# Case insensitive string compare I'm trying to do a case-insensitive comparison without using Compare or ToLower: var user = db.Users.FirstOrDefault(s => String.Equals(s.Username, username, StringComparison.OrdinalIgnoreCase)); However I get an error: Incorrect number of arguments supplied for call to method 'Boolean Equals(System.String, System.String, System.StringComparison)' What am I doing wrong?

    Read the article

  • Handling xml files with different structures and different names

    - by zachary
    I have a method and I want different users to pass me xml files. These files will have different names for the elements I am looking for and the elements I am looking for maybe at different structures. My first impression was that we should just tell them to pass in the xml in a standard format. However this is how they have their data and they insist that it is much easier if they don't have to convert it. What can I do to take in data of all types? Have them pass in a dictionary? number = mydata/numbers What is the easiest way for them to define their data to me without actually changing it? sample1 <numbers> 15 </numbers> sample2 <mydata> <mynumbers> 15 </mynumbers> </mydata>

    Read the article

  • How to implement a left outer join in the Entity Framework.

    - by user206736
    I have the following SQL query:- select distinct * from dbo.Profiles profiles left join ProfileSettings pSet on pSet.ProfileKey = profiles.ProfileKey left join PlatformIdentities pId on pId.ProfileKey = profiles.Profilekey I need to convert it to a LinqToEntities expression. I have tried the following:- from profiles in _dbContext.ProfileSet let leftOuter = (from pSet in _dbContext.ProfileSettingSet select new { pSet.isInternal }).FirstOrDefault() select new { profiles.ProfileKey, Internal = leftOuter.isInternal, profiles.FirstName, profiles.LastName, profiles.EmailAddress, profiles.DateCreated, profiles.LastLoggedIn, }; The above query works fine because I haven't considered the third table "PlatformIdentities". Single left outer join works with what I have done above. How do I include PlatformIdentities (the 3rd table) ? I basically want to translate the SQL query I specified at the beginning of this post (which gives me exactly what I need) in to LinqToEntities. Thanks

    Read the article

  • Update a record in L2S and L2E

    - by 5YrsLaterDBA
    I was told in L2S, the code for update and insert are the same, db.InsertOnSubmit(row); db.SubmitChanges(); and L2S will check to see if it is a insert or update and act approprately in the background. Is that true? How about L2E? I tested, looks like in L2E it is not like that. Maybe I did something wrong.

    Read the article

  • How to create custom get and set methods for Linq2SQL object

    - by optician
    I have some objects which have been created automatically by linq2SQL. I would like to write some code which should be run whenever the properties on these objects are read or changed. Can I use typical get { //code } and set {//code } in my partial class file to add this functionality? Currently I get an error about this member already being defined. This all makes sense. Is it correct that I will have to create a method to function as the entry point for this functionality, as I cannot redefine the get and set methods for this property. I was hoping to just update the get and set, as this would mean I wouldn't have to change all the reference points in my app. But I think I may just have to update it everywhere.

    Read the article

  • How do I save an object that contains and EntitySet?

    - by Pete
    Say I have an User (mapped to a User table) and the Edit view (in MVC) displays a multiselectlist of Modules (mapped to a Modules table) that user can access, with the Modules pre-selected based on the User's EntitySet of Modules. I have tried saving the User then deleting all User_Modules manually and adding them back based on what's selected on submit, but the User has a null EntitySet for User.User_Modules. I cannot find the correct way to handle this scenario anywhere online. Can anyone help?

    Read the article

  • DataContext Refresh and PropertyChanging & PropertyChanged Events

    - by Scott
    I'm in a situation where I am being informed from an outside source that a particular entity has been altered outside my current datacontext. I'm able to find the entity and call refresh like so MyDataContext.Refresh(RefreshMode.OverwriteCurrentValues, myEntity); and the properties which have been altered on the entity are updated correctly. However neither of the INotifyPropertyChanging INotifyPropertyChanged appear to be raised when the refresh occurs and this leaves my UI displaying incorrect information. I'm aware that Refresh() fails to use the correct property getters and setters on the entity to raise the change notification events, but perhaps there is another way to accomplish the same thing? Am I doing something wrong? Is there a better method than Refresh? If Refresh is the only option, does anyone have a work around?

    Read the article

< Previous Page | 86 87 88 89 90 91 92 93 94 95 96 97  | Next Page >