score:2
Accepted answer
my guess is that one of the methods createset, oftype and asenumerable is declared as an extension method with a this-parameter called "source", and codecontrcts can't prove it is not null. also, don't you need to add a requires clause to specify that _uow is non-null on entry?
createset appears to be the extension method since it doesn't appear in msdn. if the method should never return null, you can enforce this by adding this contract to createset
:
contract.ensures(contract.result<t>() != null);
when the codecontracts analyzer sees this rule, it will take it as proof that the input to oftype
will not be null, and the warning should go away.
Source: stackoverflow.com
Related Query
- ERROR Static method requires null instance, non-static method requires non-null instance
- LINQ Source Code Available
- C# Code Contracts -- How to ensure that a collection of items contains items with unique properties?
- .NET 4 Code Contracts: "requires unproven: source != null"
- EF Code First comparing null values generates strange query
- SQL Trigger is trying to insert a null value but my C# code is passing int 300?
- creating Linq to sqlite dbml from DbLinq source code
- Running different code depending on what Net Framework version is installed
- Is there any way to make Code Contracts work with LINQ?
- linq null refactoring code
- Null reference exception in my LINQ to XML code
- ASP.net Getting Max Date of database Date column How to avoid Null in Date Column C# My code Attached
- How to handle nulls in this LINQ Code using a possible null List?
- source code for LINQ 101 samples
- Linq query null check in data source
- Include null cells in Linq query from DB in C# code
- expr. tree: Static method requires null instance, non-static method requires non-null instance
- List or Array of String Contain specific word in Html Source Code
- c# Linq or code to extract groups from a single list of source data
- Generated DBML code incorrectly marks returned columns as NOT NULL for stored procedures
- where Clause in Asp.net is returning null exception in the code below
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- How to check if IEnumerable is null or empty?
- FirstOrDefault: Default value other than null
- Value cannot be null. Parameter name: source
- LINQ order by null column where order is ascending and nulls should be last
- An expression tree lambda may not contain a null propagating operator
- Linq code to select one item
- C# - code to order by a property using the property name as a string
More Query from same tag
- Linq query with a Join, not returning the correct results
- SQL data table and lookup table in query
- Linq to NHibernate return entities whose name starts with contents of string list
- Sorting using C# , LINQ
- retrieve data with Contains id
- C# Linq Convert Object Property to Array
- Linq solution to get greatest numbers of arrays
- LINQ-2-SQL expansion of relationships on ToList()
- C# Linq and Regexing non-unicode
- Filter datatable against DataRow array
- complex query using LINQ and C#
- How to create a dynamic 'contains or LIKE' Expression to be used with Linq against OData service
- How do I use LINQ to access a specific value from of an array of JObjects that seems to be stored in a string
- Merge Datatable records using LINQ
- How to find an error in Linq using PropertyValidationErrors when key is not found in results
- ASP.NET MVC LINQ query
- How to get text from LINQ to SQL query into a TextBox?
- How to order in duplicates of 2?
- XML Serializable IQueryable<T>/Expression Tree
- Entity Framework LINQ query starts timing out - speeds up again after DB server reboot
- Select from table using model properties that is not null
- Linq distinct over multiple columns into dictionary
- LINQ query Joins
- linq to sql fetching all the records category wise in the list<> and then looping
- Iterate over array of strings and replace if exists
- Distinct of items in dictionary<T,IEnumerable<T>>
- System.Linq.Dynamic.DynamicExpression parsing expressions with enum parameters
- Linq query-dateOfBirth to age
- Does Linq/.NET3.5 support a 'zip' method?
- LINQ get parent with most children