Search Results

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

Page 115/249 | < Previous Page | 111 112 113 114 115 116 117 118 119 120 121 122  | Next Page >

  • Best algorithm/practice when creating a search mechanism for your database?

    - by Alex Hope O'Connor
    I have been designing a database where it is very important to provide users with a good search mechanism. So I was wondering what some of the best practices are for using keywords to search over multiple database tables and return the relevent records? Some other things I am curious about: The users location, if they provide an address The speed of the algorithm Additional Information: I am using C# and LINQ-To-SQL.

    Read the article

  • LINQPad still being used much out there?

    - by CoffeeAddict
    I'm trying to guage how popular and how used LINQPad is today. I'm just wondering if it's still a useful tool or not as VS and other tools have gotten better. Furthermore, I am coding over LLBGen by working with LINQ to SQL. I see there is a plug-in for LLBGen and LINQPad. Still I wonder if LINQPad is really worth it or what benefits it can give me or if it's still highly suggested out there for ORMs, etc.

    Read the article

  • T-SQL selecting values that match ISNUMERIC and also are within a specified range. (plus Linq-to-sql

    - by Toby
    I am trying to select rows from a table where one of the (NVARCHAR) columns is within a numeric range. SELECT ID, Value FROM Data WHERE ISNUMERIC(Value) = 1 AND CONVERT(FLOAT, Value) < 66.6 Unfortunately as part of the SQL spec the AND clauses don't have to short circuit (and don't on MSSQL Server EE 2008). More info: http://stackoverflow.com/questions/789231/is-the-sql-where-clause-short-circuit-evaluated My next attempt was to try this to see if I could achieve delayed evaluation of the CONVERT SELECT ID, Value FROM Data WHERE (CASE WHEN ISNUMERIC(Value) = 1 THEN CONVERT(FLOAT, Value) < 66.6 ELSE 0 END) but I cannot seem to use a < (or any comparison) with the result of a CONVERT. It fails with the error Incorrect syntax near '<'. I can get away with SELECT ID, CONVERT(FLOAT, Value) AS Value FROM Data WHERE ISNUMERIC(Value) = 1 So the obvious solution is to wrap the whole select statement in another SELECT and WHERE and return the converted values from the inner select and filter in there where of the outer select. Unfortunately this is where my Linq-to-sql problem comes in. I am filtering not only by one range but potentialy by many, or just by the existance of the record (there are some date range selects and comparisons I've left out.) Essentially I would like to be able to generate something like this: SELECT ID, TypeID, Value FROM Data WHERE (TypeID = 4 AND ISNUMERIC(Value) AND CONVERT(Float, Value) < 66.6) OR (TypeID = 8 AND ISNUMERIC(Value) AND CONVERT(Float, Value) > 99) OR (TypeID = 9) (With some other clauses in each of those where options.) This clearly doesn't work if I filter out the non-ISNUMERIC values in an inner select. As I mentioned I am using Linq-to-sql (and PredicateBulider) to build up these queries but unfortunately Datas.Where(x => ISNUMERIC(x.Value) ? Convert.ToDouble(x.Value) < 66.6 : false) Gets converted to this which fails the initial problem. WHERE (ISNUMERIC([t0].[Value]) = 1) AND ((CONVERT(Float,[t0].[Value])) < @p0) My last resort will have to be to outer join against a double select on the same table for each of the comparisons but this isn't really an idea solution. I was wondering if anyone has run into similar issues before?

    Read the article

  • how to insert using linq to entity foreign key value?

    - by Gamble
    I have a table (TestTable) for example: ID Name Parentid (FK) and I would like to insert a new record like ID(1) Name(Test) ParentID(5) FK. How can insert a new record into TestTable with linq to entity? var testTable = new TestTable(); testTable.ID = 1; testTable.Name = "TestName"; testTable ... thank you for the working example.

    Read the article

  • How to rewrite this SQL statement to LINQ 2 SQL ?

    - by Shyju
    How can i convert this SQL query to its equivalent LINQ 2 SQL statement for VB.NET? SELECT COUNT(*) AS 'Qty', IV200.itemnmbr, IV200.locncode, IV200.bin, CAST(IV112.Quantity as int) as 'Qty2' , 'parentBIN' = isnull(MDS.parentBIN,iv112.bin) From IV00200 IV200 (nolock) inner join IV00112 IV112 (nolock) on iv200.itemnmbr = iv112.itemnmbr and IV200.bin = IV112.bin and iv200.locncode = iv112.locncode left outer join mds_container mds (nolock) on isnull(mds.locncode,'nul') = isnull(iv112.locncode,'nul') and isnull(mds.containerbin,'nul') = isnull(iv112.bin,'nul') where IV200.bin = 'MU7I336A80' group by IV200.itemnmbr, IV200.locncode, IV200.bin, IV112.Quantity, isnull(MDS.parentBIN,iv112.bin) order by IV200.itemnmbr

    Read the article

  • Is there a way to add or remove a line of an LINQ to DB Query based on if the value being checked is

    - by RandomBen
    If I have a query like this: String Category = HttpContext.Current.Request.QueryString["Product"].ToString(); IQueryable<ItemFile> pressReleases = from file in connection.ItemFile where file.Type_ID == 8 && file.Category == Category select file; Is there a way to make this LINQ Query so that I do no use the line file.Category == Category if Category is null or empty?

    Read the article

  • Linq/C#: Selecting and summing items from the result of a group by?

    - by Andrew White
    Hi, I have a list like this: City Total Sydney 11 Dublin 9 London 12 Dublin 3 London 9 Sydney 12 I first of all need to Group By City & Sum Total so I have Sydney 23 Dublin 12 London 21 Next I need to filter for those that entries where the total is 20 Sydney 23 London 21 And what I finally need is the total of these entries, e.g. 44 I really want to do it in 1 single LINQ statement, possible? Thx,

    Read the article

  • VB .Net LINQ query to determine whether more than one element has the same value for a property?

    - by Alex Hope O'Connor
    I am trying to write a LINQ query which will return true if there are multiple objects which have a property with the same value. Here is what I have come up with so far: Formatters.Where(Function(f As DataModel.Formatter) _ Formatters.Select(Function(f2 As DataModel.Formatter) f2.Name.ToLower()).Contains(f.Name.ToLower())).Count > 1 However the above always returns true as long as their are more then 1 elements in the list, can someone please give me a hand with this? Thanks, Alex.

    Read the article

  • What is the most elegant way to implement a business rule relating to a child collection in LINQ?

    - by AaronSieb
    I have two tables in my database: Wiki WikiId ... WikiUser WikiUserId (PK) WikiId UserId IsOwner ... These tables have a one (Wiki) to Many (WikiUser) relationship. How would I implement the following business rule in my LINQ entity classes: "A Wiki must have exactly one owner?" I've tried updating the tables as follows: Wiki WikiId (PK) OwnerId (FK to WikiUser) ... WikiUser WikiUserId (PK) WikiId UserId ... This enforces the constraint, but if I remove the owner's WikiUser record from the Wiki's WikiUser collection, I recieve an ugly SqlException. This seems like it would be difficult to catch and handle in the UI. Is there a way to perform this check before the SqlException is generated? A better way to structure my database? A way to catch and translate the SqlException to something more useful? Edit: I would prefer to keep the validation rules within the LINQ entity classes if possible. Edit 2: Some more details about my specific situation. In my application, the user should be able to remove users from the Wiki. They should be able to remove any user, except the user who is currently flagged as the "owner" of the Wiki (a Wiki must have exactly one owner at all times). In my control logic, I'd like to use something like this: wiki.WikiUsers.Remove(wikiUser); mRepository.Save(); And have any broken rules transferred to the UI layer. What I DON'T want to have to do is this: if(wikiUser.WikiUserId != wiki.OwnerId) { wiki.WikiUsers.Remove(wikiUser); mRepository.Save(); } else { //Handle errors. } I also don't particularly want to move the code to my repository (because there is nothing to indicate not to use the native Remove functions), so I also DON'T want code like this: mRepository.RemoveWikiUser(wiki, wikiUser) mRepository.Save(); This WOULD be acceptable: try { wiki.WikiUsers.Remove(wikiUser); mRepository.Save(); } catch(ValidationException ve) { //Display ve.Message } But this catches too many errors: try { wiki.WikiUsers.Remove(wikiUser); mRepository.Save(); } catch(SqlException se) { //Display se.Message } I would also PREFER NOT to explicitly call a business rule check (although it may become necessary): wiki.WIkiUsers.Remove(wikiUser); if(wiki.CheckRules()) { mRepository.Save(); } else { //Display broken rules }

    Read the article

  • How can I iterate over a collection of objects returned by a LINQ-to-XML query?

    - by billmaya
    I've got this XML: <BillingLog> <BillingItem> <date-and-time>2003-11-04</date-and-time> <application-name>Billing Service</application-name> <severity>Warning</severity> <process-id>123</process-id> <description>Timed out on a connection</description> <detail>Timed out after three retries.</detail> </BillingItem> <BillingItem> <date-and-time>2010-05-15</date-and-time> <application-name>Callback Service</application-name> <severity>Error</severity> <process-id>456</process-id> <description>Unable to process callback</description> <detail>Reconciliation timed out after two retries.</detail> </BillingItem> </BillingLog> That I want to project using LINQ-to-XML into a collection of BillingItem objects contained in a single BillingLog object. public class BillingLog { public IEnumerable<BillingItem> items { get; set; } } public class BillingItem { public string Date { get; set; } public string ApplicationName { get; set; } public string Severity { get; set; } public int ProcessId { get; set; } public string Description { get; set; } public string Detail { get; set;} } This is the LINQ query that I'm using to project the XML (which is contained in the string variable source). XDocument xdoc = XDocument.Parse(source); var log = from i in xdoc.Elements("BillingLog") select new BillingLog { items = from j in i.Descendants("BillingItem") select new BillingItem { Date = (string)j.Element("date-and-time"), ApplicationName = (string)j.Element("application-name"), Severity = (string)j.Element("severity"), ProcessId = (int)j.Element("process-id"), Description = (string)j.Element("description"), Detail = (string)j.Element("detail") } }; When I try and iterate over the objects in log using foreach. foreach (BillingItem item in log) { Console.WriteLine ("{0} | {1} | {2} | {3} | {4} | {5}", item.Date, item.ApplicationName, item.Severity, item.ProcessId.ToString(), item.Description, item.Detail); } I get the following error message from LINQPad. Cannot convert type 'UserQuery.BillingLog' to 'UserQuery.BillingItem' Thanks in advance.

    Read the article

  • LINQ Group By to project into a non-anonymous type?

    - by vikp
    Hi, I have the following LINQ example: var colorDistribution = from product in ctx.Products group product by product.Color into productColors select new { Color = productColors.Key, Count = productColors.Count() }; All this works and makes perfect sense. What I'm trying to achieve is to group by into a strong type instead of anonymous type. For example I have a ProductColour class and I would like to Group into a List<ProductColour> Is this possible? Thank you

    Read the article

  • Get the count of items in a GroupBy Linq-to-sql Query?

    - by Curtis White
    I have a groupby that I groups all elements. I can see the items are there in LinqPad but can't find a way to get the count. Here is what I have so far: SurveyResponses.Where( q = q.QuestionId == 4).GroupBy(q = q.AnswerNumeric).Where( g = g.Key == 1) In Linq Pad I can see there are 4 items in this query. If I do Count it returns 1. I've tried, ToList().Count, Select(x = x).Count, etc.

    Read the article

  • LINQ how to add an order by to this statement?

    - by JL
    I have the following LINQ that I would like to also order by file creation date, how is this done? taskFiles = taskDirectory.GetFiles(Id + "*.xml") .Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase)) .ToArray();

    Read the article

  • How to use LINQ to query list of strings that do not contain substring entries from another list

    - by p.campbell
    string candidates = new string[] { "Luke_jedi", "Force_unknown", "Vader_jedi" , "Emperor_human", "r2d2_robot" }; string[] disregard = new string[] {"_robot", "_jedi"}; //find those that aren't jedi or robots. var nonJedi = candidates.Where(c=> c.??? //likely using EndsWith() and Any() ); How would you implement this solution using LINQ to find all those that do not end with any of the disregards items?

    Read the article

  • How to wrap LINQ to SQL queries in stored proc?

    - by Satish
    LINQ to SQL internally generates SQL queries and fire on the database after submitting changes. Is there any way we can wrap all these queries in some stored procedure and execute this store proc everytime when anything gets inserted or updated in the database. Problem is only stored procedures are allowed to carry any insert or update or delete operations, direct queries are restricted for security purpose.

    Read the article

< Previous Page | 111 112 113 114 115 116 117 118 119 120 121 122  | Next Page >