ADO.NET :: How To Declare Multiple Groups In LINQ

Aug 17, 2010

How can I declare multiple groups in LINQ? I get this error "Range variable 'Group' is already declared." Error found in bold and underlined text below.

Dim SportsWear = From c in dbContext.SportsTable Group Join grp_Attire In dbContext.AttireTable On grp_Attire.AttireId Equals c.AttireId Into Group From sportsAttire In Group.DefaultIfEmpty() Group Join grp_SportType In dbContext.SportType On grp_SportType.TypeId Equals c.TypeId Into Group From sportsType In Group.DefaultIfEmpty() Select New With { _ .Attire = sportsAttire.AttireName,.Type = sportsType.TypeName}

View 1 Replies


Similar Messages:

MVC :: 2 - Dynamic View Content - Render A Page That Will Have Multiple Radio Button Groups As Well As Multiple CheckBoxes

Aug 4, 2010

I have an application that needs to render a page that will have multiple Radio Button Groups as well as multiple CheckBoxes. The desired layout is determined by a database table.

table structure:
PackageID uniqueidentifier
PackageName string
ItemName string
RadioGroupName string
ViewControlName string

This table defines a "Package". The "Package" can contain many different "Items" that require different controls used in the View. The "RadioGroupName" field is used to mark which RadioButtons should be grouped together. The "ViewControl" field marks which control should be used on the View to display the field. The query in my repository will return a result set such as

1 / "First Package" / "Item1" / "First Group" / "RadioButton"
2 / "First Package" / "Item2" / "First Group" / "RadioButton"
3 / "First Package" / "Item3" / "First Group" / "RadioButton"
4 / "First Package" / "Item4" / null / "CheckBox"
5 / "First Package" / "Item5" / null / "CheckBox"
6 / "First Package" / "Item6" / "Second Group" / "RadioButton"
7 / "First Package" / "Item7" / "Second Group" / "RadioButton"
8 / "First Package" / "Item8" / "Second Group" / "RadioButton"

Given this result set, I need to render the view as follows:

A RadioButton group with 3 options (Item1, Item2, Item3)
A CheckBox (Item4)
A CheckBox (Item5)
A RadioButton group with 3 options (Item6, Item7, Item8)

I have read that it is possible to use "if" conditions and looping structures inside the View. I have also read that this is a bad practice. Another issue I see is knowing which Item has been selected from each RadioButton group when I hit the Controller POST function. Previously I have built a page that has a single RadioButton group. My ViewModel was as follows:

[Code].........................

View 1 Replies

C# - How To Validate Against Multiple Validation Groups

Mar 14, 2011

I have a Form like this.

UserID has to be validated when user clicks "Check Availability" and "Submit"

Hence "UserID" required field validator has to be assigned two grops.

As if now it is assigned only Group1

[code]....

I have already gone through How to validate against Multiple validation groups?

which talks about validating Group1 and Group2 when user clicks "Submit" which is a good alternate solution.

View 1 Replies

How To Validate Against Multiple Validation Groups

Mar 24, 2010

I have two validation groups: parent and child

I have an add button that needs to only validate the child validation group which is easily done. The save button needs to validate against the parent and child validation groups, both client side and server side. I think I know how to do it server side by calling the Page.Validate("groupname") method for each group, but how can it be done client side?

View 1 Replies

Validation Rule Belong To Multiple Groups?

Feb 18, 2010

Is it possible for an ASP.NET Validation Rule to belong to multiple groups? I'd like to validate the same control in different ways based on what mode the form is in using a single Validator. For the purposes of this question, the modes are Simple, which requires fewer fields, or Complex, which requires more fields. I know I can write CustomValidators (which I have done in the past), but I'd like a simpler solution.

So, I'd like to combine the following:

<asp:RequiredFieldValidator ValidationGroup="Simple" ControlToValidate="Name" />
<asp:RequiredFieldValidator ValidationGroup="Complex" ControlToValidate="Name" />

View 2 Replies

Security :: Web.config Authorization Roles With Local Groups With Domain Groups In Them

Sep 29, 2010

I am "DomainMyDomainUserName" If I do this:

[Code]....

I can access the website I've created on my local machine in debug mode; and with my domain account as a local administrator, if I do this:

[Code]....

I can still access the website; and with my domain account in a Domain Group named "DomainDomainLocalSecurityGroup", if I do this:

[Code]....

I can still access the website; HOWEVER, if I create a Local Group on my machine named "LocalMachineGroup" and I add "DomainMyDomainUserName" to this group and I do this:

[Code]....

I get an Access Denied error trying to access the website. What I want to do is, have a group on my local machine (for testing), on a test web server, and on a production web server named "MyWebsiteUserAccess" with the same Domain Group (filled with Domain Users allowed access to the site) in all of these local groups; so that when I test the web application on my local machine, on my test web server and on my production web server, I don't have to change the Web.config file to have it work on each AND if the Domain Group name ever has to change, it won't affect access to the website.

What am I overlooking or is this even possible to do this way? I understand that there is a way to do Role Management through ASP.NET but I don't understand that well enough yet to implement that (and will probably go that route once I've done the research on how to best implement it for purpose of access control of this intranet site).

View 2 Replies

Enumerating Groups Using WindowsIdentity.GetCurrent() Returns Old Set Of Groups

Feb 1, 2011

I have a user that when I attempt to enumerate her groups using either System.Security.Principal.WindowsIdentity.GetCurrent().Groups on user's computer
or System.Web.HttpContext.Current.Request.LogonUserIdentity.Groups on the IIS server, I get a list of their old groups, not their new. I have checked the DC that they authenticate to and the ASP.NET page is running inside a SharePoint instance so the LogonUserIdentity most like is being provided from there Kerberos ticket.
Should I be looking up the groups directly from the AD instead of relying on the WindowsIdentity or LogonUserIdentity?

View 1 Replies

C# - Get Local Groups And Not The Primary Groups For A Domain User

Dec 18, 2010

i have a code to get the groups a user belongs to.

try
{
DirectoryEntry adRoot = new DirectoryEntry(string.Format("WinNT://{0}", Environment.UserDomainName));
DirectoryEntry user = adRoot.Children.Find(completeUserName, "User");
object obGroups = user.Invoke("Groups");
foreach (object ob in (IEnumerable)obGroups)
{
// Create object for each group.
DirectoryEntry obGpEntry = new DirectoryEntry(ob);
listOfMyWindowsGroups.Add(obGpEntry.Name);
}
return true;
}
catch (Exception ex)
{
new GUIUtility().LogMessageToFile("Error in getting User MachineGroups = " + ex);
return false;
}

the above code works fine when i have to find the groups of a local user but

for a domain user it returns a value "Domain User" which is kind of wierd as it is a part of 2 local groups.

Research

I did some finding and got that i am being returned the primary group of the domain user

called "Domain User" group

but what i actually want is the groups of the local machines the domain user is a part of... i cannot get that.. any suggestions

another code using LDAP

string domain = Environment.UserDomainName;
DirectoryEntry DE = new DirectoryEntry("LDAP://" + domain, null, null, AuthenticationTypes.Secure);
DirectorySearcher search = new DirectorySearcher();
search.SearchRoot = DE;
search.Filter = "(SAMAccountName=" + completeUserName + ")"; //Searches active directory for the login name
search.PropertiesToLoad.Add("displayName"); // Once found, get a list of Groups
try
{
SearchResult result = search.FindOne(); // Grab the records and assign them to result
if (result != null)
{
DirectoryEntry theUser = result.GetDirectoryEntry();
theUser.RefreshCache(new string[] { "tokenGroups" });
foreach (byte[] resultBytes in theUser.Properties["tokenGroups"])
{
System.Security.Principal.SecurityIdentifier mySID = new System.Security.Principal.SecurityIdentifier(resultBytes, 0);
DirectorySearcher sidSearcher = new DirectorySearcher();
sidSearcher.SearchRoot = DE;
sidSearcher.Filter = "(objectSid=" + mySID.Value + ")";
sidSearcher.PropertiesToLoad.Add("distinguishedName");
SearchResult sidResult = sidSearcher.FindOne();
if (sidResult != null)
{
listOfMyWindowsGroups.Add((string)sidResult.Properties["distinguishedName"][0]);
}
}
}
else
{
new GUIUtility().LogMessageToFile("no user found");
}
return true;
}
catch (Exception ex)
{
new GUIUtility().LogMessageToFile("Error obtaining group names: " + ex.Message + " Please contact your administrator."); // If an error occurs report it to the user.
return false;
}

this works too but i get the same result "Domain Users" . Please can some1 tell me how to get the local machine groups...?

View 2 Replies

Web Forms :: Multiple Validation Groups,validate Only One On 1 Submit Button?

Mar 7, 2011

I have two validation groups 'Sub' and 'Normal'and i have some checkboxes . .

I need to validate depending on value of checkbox how to do this . .

View 5 Replies

Web Forms :: To Validate Multiple validation Groups With The Click Of One Button?

Apr 1, 2010

I need to be able to validate multiple validation groups with the click of one button. My Form consists of two text boxes and a drop down list for input. The form also, currently, has three buttons, one for each control. Each of those buttons are tied to a validation control and if the validation is successful, it will add the user inputted data into a database that I have. The interesting part comes when I need to add a forth button which will act as a "Save All" Button. When this button is clicked, I need it to fire the three validation groups.

Is it possible to add multiple validation groups to the "Save All" Button?

View 2 Replies

Data Controls :: Validate Multiple Validation Groups In GridView

May 7, 2015

I have a Dynamic GridView on a page as below. The user can add or delete rows. When inserting record, the code is executed one row at a time. I have 3 rows to be inserted to the database. Here is the issue:

-if the first row is not completed, then no record is added to the database

-if the first row is completed and the second row is not, then only the first row is inserted in the database

-if the first row is completed, the second row is not complete, and the third row is completed, then only the first row is inserted in the database.

below is the code:

protected void GridView1_AddNewRecord(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["DatabaseVestConnectionString1"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd;
string query1 = "INSERT INTO kart_Bestilling(SakBehandlingCode, KystverketRegionID, KystverketAvdelingID, BestillerReferanse, BestillerLeveringAdresse, BestillerPostKodeBy, BestillerNavn, BestillerStilling, BestillerEpost, BestillerTelefon, BestillingBeskrivelse, BestillingDato, BehandlingSakNummer, BehandlingBeskrivelse, BehandlingStatus)" +

[code]...

How to arrange this piece of code to validate all rows before any insert? or avoid inserting a row if there is one row not complete?the conditions starts with int rowIndex = 0;

if (txtBestillerReferanse.Text != "" && txtBestillerEpost.Text != "" && txtBestillerNavn.Text != "" && txtBestillerPostKodeBy.Text != "" && ddKartTypeName.SelectedValue != "Velg KartType" && ddKartNummerName.SelectedValue != "Velg KartNummer" && tBestillingAntallKart1.Text != "")

View 1 Replies

SQL Server :: Post Multiple Declare Statements?

Oct 26, 2010

I know how to do this with 1 declare statement, but for this there are multiple one's. This example sql statement has 2, however my actual one will have 29.

[Code]....

View 14 Replies

Using LINQ To Surround All "group" Elements With The New Element "groups" In C#?

Mar 1, 2011

I'm new to LINQ and C# but I have an xml file generated from a database table. Within the XML document is a element called "group", I would like to wrap all group elements with the element called "groups".

An extract of the XML document is:

[Code]....

View 2 Replies

C# - LINQ To Entity Framwework Multiple Joins With Multiple Dynamic Search Criteria?

Jul 2, 2010

The gist of the problem is that we have an alumni table (one record per person) and also a couple of other tables (one to many) that have degree info and interest info. In a search screen in our app you can search for criteria that spans all three tables (there are actually more fields and tables than shown in the example below but I am trying to keep it simple).

The code below works (properly returns people without degrees for example) but still feels a little clunky or over-engineered to me. Are there easier ways to do this? NOTE: I have been through quite a few iterations/approaches to making the correct data be returned.

[code]....

View 1 Replies

ADO.NET :: LINQ To SQL - Multiple Joins With Multiple Conditions?

Jan 28, 2011

I have some problems trying to query my database. The problem is that I'm not sure how to multiple join tables in my database.

tables to make it easier:

[code]....

What I'm supposed to do is to find all the teachers (predavac) who were teachers on the specific activity (aktivnost) and who had specific attendee (polaznik). The problem is I'm not sure how to do multiple joins on this one.

View 1 Replies

ADO.NET :: Linq Multiple Where From Second Table

Dec 16, 2010

Tables:

WORKORDER and CUSTFIELD

Fields:

WORKORDER = WORKORDERID

CUSTFIELD = WORKORDERID, CUSTFIELDNAME, CUSTFIELDVALUE

There are multiple different type of name/value pairs. I want to specifically return the custfield value where custfield name is "INCIDENT", and the custfield value where custfield name is "NETWORK" all for the appropriate WORKORDERID

I've tried a few different ways and just can't grasp how the linq is supposed to go to get the results I want. I can get an incident value, or network value, but not both.

I have the proper association set up in the dbml so both of these work to get the single value:

var b = from i in edcwdv.WOCUSTFIELDs join p in edcwdv.WORKORDERs on i.WORKORDERID equalsp.WORKORDERID where i.CUSTFIELDNAME.Contains("INCIDENT") select new { i.CUSTFIELDNAME, i.CUSTFIELDVALUE, p.WORKORDERID };
var incident = from wo in edcwdv.WORKORDERs orderby wo.WORKORDERID where wo.WOCUSTFIELDs.CUSTFIELDNAME.Contains("INCIDENT") select new { wo.WORKORDERID, wo.WOCUSTFIELDs.CUSTFIELDVALUE}; So essentially i want to pull the value for each of the fields, INCIDENT and NETWORK

View 2 Replies

C# - Send Multiple Emails (via LINQ To SQL)?

Jun 13, 2010

The objective is to send automated emails to which of whom come from the results of my LINQ to SQL script. As I am not sure on 'automated' stuff I was going to approach this in the aspect of having a field in the table that the results are taken from change after the emails have been sent i.e. obj.EmailSent = true; - So that everytime the admin homepage is loaded it isnt sending it out again (eliminating duplication).

From that I would have to create a method to detect a new year and upon that reset all entries of the EmailSent field in the DB table to 'false', but for now its just the initial problem thats causing confusion.

I was going to opt for a 'foreach' solution so that all the recipients, individually, get their emails and not all together. Its the 'foreach' I'm not sure on as well as setting all the results collected to the new value of 'EmailSent' to 'true'.

Here is my attempt:

C#:

[code]....

View 9 Replies

ADO.NET :: Linq On Multiple Tables With Same Columns

Aug 17, 2010

I have a partitioned db where several tables have the exact same structure. I'm able to query the tables using linq, but only by quering the individual tables 1 at a time and by using the explicit table name. For example at the moment, I have 8 tables so I have something similar to the following:

[Code]....

Is there any way, that based on a certain value (stringValue), I could determine which table to query and then code the linq query just once?

View 2 Replies

ADO.NET :: Searching Through Multiple Tables (Linq To SQL)?

Aug 12, 2010

I have a couple tables that are kind of unrelated - id like to search through both of them and create a type that i can sift through later

something like this doesnt work

[Code]....

I basically want to create a list of "AnimalSearchResults" that contains all dogs and all cats that have that name Whats the best way to do something like this?

View 6 Replies

C# - Linq To Sql Making Multiple Calls In .net Mvc 3

Mar 18, 2011

When I am updating a record with linq to sql my DeleteLesson() method is getting called multiple times.My controller looks like this :

public ActionResult Delete(int id)
{

deleteLesson(id);[code]....

EDIT.also if I use confirm = "Do you want to delete" in ajax options I will have to click okay three times.

View 1 Replies

IQueryable Linq To SQL With Multiple Operators

Jul 4, 2010

I'm creating a repository and service layer in my app, and my repo has a very simple function

Public Function GetRegions() As IQueryable(Of Region) Implements IRegionRepository.GetRegions
Dim region = (From r In dc.Regions
Select r)
Return region.AsQueryable
End Function

Now in my Service layer I've got a function like this

Public Function GetRegionById(ByVal id As Integer) As Region Implements IRegionService.GetRegionById
Return _RegionRepository.GetRegions().Where(Function(r) r.ID = id).FirstOrDefault
End Function

But i can't figure out how to add And r.isActive = True

how to have multiple operators in this query?

View 3 Replies

C# - Linq - Group By Multiple Tables?

Aug 8, 2010

Using Linq to Sql how do i group the following 2 tables.

Orders Table:

CustomerID | Name |Date
1 | order1 | 2010-01-01
2 | order2 | 2010-01-01
2 | order3 | 2010-04-01

Calls Table:

CustomerID | Name |Date
1 | call1 | 2010-01-01
3 | call2 | 2010-06-01
2 | call3 | 2010-05-01

I want to group the two tables by date , Result:

Date | Orders | Calls
2010-01-01 | 2 | 1
2010-04-01 | 1 | 0
2010-05-01 | 0 | 1
2010-06-01 | 0 | 1

i know how to group a single table ,from o in Orders group o by o.Date.Date into og select new {Date = og.Key,Orders= og.Count()};

View 2 Replies

ADO.NET :: Linq To SQL Transactions With Multiple Deletes?

Sep 29, 2010

I am trying to delete three related objects on one submit. Delete fails on one of the child objects, because of foreign key contraint with another table, It deletes one (the parent) but not the two child objects. All in one SubmitChanges(). I even used the TransactionScope, still same thing. So here is the scenario:

I have an object called Page which has a collection of objects called Webinars. There is another object Called Product which is one to one with Webinar.

[Code]....

View 5 Replies

ADO.NET :: LINQ Multiple Categories For Product?

Jan 27, 2011

I'm using Entity Framework.

I have 3 tables:

- Products (Primary key productId)
- Categories (Primary key categoryId)
- Product_to_categories (Table with two fields, CategoryId and ProductId)

One product can be assigned to multiple categories.

How should I download the products from specific category?

Now I retrieve them in that way:

int PageNum = 1;
int PageSize = 10;
int categoryId = 5;
var categoryModel = db.Categories.FirstOrDefault(c => c.CategoryId == categoryId);
var results = (from p in categoryModel.Products select p).Skip((PageNum - 1) * PageSize).Take(PageSize).ToList();

But when there is a lot of products in category my server crushed. I want only 10 products per page.

View 2 Replies

ADO.NET :: LINQ To Entity Multiple Rows WCF?

Dec 15, 2010

I am selecting some products from database and would like to show them in client's grid using WCF. Problem is I don't know how to pass selected collection to the client since my method can't return that data type.

My method:

public class Service1 : IService1
{
public ProductData GetData(int value)
{
using( NorthwindEntities NWEntities = new NorthwindEntities()){

[Code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved